最新电大C语言程序设计课程期末复习考试题库小抄(c语言小题编程)

上传人:沈*** 文档编号:82632428 上传时间:2022-04-29 格式:DOC 页数:5 大小:55KB
返回 下载 相关 举报
最新电大C语言程序设计课程期末复习考试题库小抄(c语言小题编程)_第1页
第1页 / 共5页
最新电大C语言程序设计课程期末复习考试题库小抄(c语言小题编程)_第2页
第2页 / 共5页
最新电大C语言程序设计课程期末复习考试题库小抄(c语言小题编程)_第3页
第3页 / 共5页
点击查看更多>>
资源描述
最新电大C语言程序设计课程期末复习考试题库小抄 一、单选题 1在每个C语言程序中都必须包含有这样一个函数,该函数的函数名为( )。 A. main B. MAIN C. name D. function 2每个C语言程序文件的编译错误分为( )类。 A. 1 B. 2 C. 3 D. 4 3. 字符串a+b=12n的长度为( )。 A. 6 B. 7 C. 8 D. 9 4. 在switch语句的每个case块中,假定都是以break语句结束的,则此switch语句容易被改写为( )语句。 A. for B. if C. do D. while 5. 在下面的do-while循环语句中,其循环体语句被执行的次数为( )。 int i=0; do i+; while(i10); A. 4 B. 3 C. 5 D. 10 6. 将两个字符串连接起来组成一个字符串时,选用的函数为( )。 A. strlen() B. strcap() C. strcat() D. strcmp() 7. 若用数组名作为函数调用的实参,传递给形参的是( )。 A. 数组的首地址 B. 数组中第一个元素的值 C. 数组中全部元素的值 D. 数组元素的个数 8. 假定a为一个整数类型的数组名,整数类型的长度为4,则元素a4的地址比a数组的首地址大( )个字节。 A. 4 B. 8 C. 16 D. 32 9. 假定s被定义为指针类型char *的变量,初始指向的字符串为Hello world!,若要使变量p指向s所指向的字符串,则p应定义为( )。 A. char *p=s; B. char *p=&s; C. char *p;p=*s; D. char *p; p=&s; 10. 从一个数据文件中读入以换行符结束的一行字符串的函数为( )。 A. gets() B. fgets() C. getc() D. fgetc() 11. 由C语言目标文件连接而成的可执行文件的缺省扩展名为( )。 A. cpp B. exe C. obj D. c 12. 设有两条语句为“int a=12; a+=a*a;”,则执行结束后,a的值为( )。 A. 12 B. 144 C. 156 D. 288 13. 带有随机函数调用的表达式rand()%20的值在( )区间内。 A. 119 B. 120 C. 019 D. 020 14. for循环语句“for(i=0; i0 & x=10)的相反表达式为( )。A. x10 B. x10C. x=0 | x0 & x10 23. 当处理特定问题时的循环次数已知时,通常采用( )循环来解决。 A. for B. while C. do-while D. switch 24. 假定i的初值为0,则在循环语句“while(ib | b=5的相反表达式为a5)的相反表达式为_(x!=0 | y=5) 或:(x | y5的相反表达式为_ x+yname等价的访问表达式为_(*p).name _。参考解答:1. ;(或分号) 2. # 3. void 4. 0x195. a=b & b!=5 6. DataType 7. 32 8. 0N-19. 1 10. 拷贝(复制) 11. 程序文件 12. *(a+i)13. *p 14. C 15. 2 16. float17. 33 18. (x!=0 | y=5) 或:(x | y=5) 19. 1 20. 60 21. BB 22. 1123. 46 24. int* 25. 12 26. x.a27. printf 28. error 29. 70 30. 1431. x+y=5 32. 10 33. 4*M 34. 235. 长度 360. 函数体 37. 46 38. &p39. (*p).name五、按题目要求编写程序或函数 1. 编写一个程序,输出50以内(含50)的、能够被3或者5整除的所有整数。#include void main() int i; for(i=3; i=50; i+) if(i%3=0 | i%5=0) printf(%d ,i); printf(n); 2. 编写一个递归函数“int FF(int a, int n)”,求出数组a中所有n个元素之积并返回。int FF(int a, int n) if(n=0) printf(n值非法n),exit(1); if(n=1) return an-1; else return an-1*FF(a,n-1); 3. 编写一个程序,利用while循环,计算并打印输出的值,其中正整数n值由键盘输入。假定求和变量用sum表示,计数变量用i表示,sum、i和n均定义为全局变量,sum和i的初值分别被赋予0和1。#include int n,i=1; double sum=0; void main() scanf(%d,&n); while(i=n) sum+=(double)1/i+; printf(sum=%lfn,sum); 4. 根据函数原型“void DD(int a, int n, int MM)”编写函数定义,利用双重循环查找并打印输出数组an中任何两个元素的值等于MM值的元素值。假定ai+aj等于MM,则输出格式为:(ai,aj)。void DD(int a, int n, int MM) int i,j; for(i=0; in; i+) for(j=i+1; jn; j+) if(ai+aj=MM) printf(%d, %dn, ai,aj); 5. 编写一个程序,计算1+3+32+.+310的值并输出,假定分别用i,p,s作为循环变量、累乘变量和累加变量的标识符。#include void main() int i; int p=1; int s=1; for(i=1;i=10;i+) p*=3; s+=p; printf(%dn,s); 6. 根据函数原型“int FF(int a, int n)”,编写函数定义,计算并返回数组an中所有元素之和。int FF(int a, int n) int i,sum=0; for(i=0; in; i+) sum+=ai; return sum; 7. 根据函数原型“double Mean(double aMN,int m,int n)”,编写函数定义,要求返回二维数组amn中所有元素的平均值。假定在计算过程中采用变量v存放累加值和最后的平均值。double Mean(double aMN,int m,int n) int i,j; double v=0.0; for(i=0; im; i+) for(j=0; jn; j+) v+=aij; v/=m*n; return v; 注:函数体的最后两行可以合并为一条返回语句:return v/=m*n 8. 根据函数原型“int MM(int a,int m)”,编写函数定义,计算并返回数组am中元素最大值和最小值之差。int MM(int a,int m) int i,x1,x2; x1=x2=a0; for(i=1; ix1) x1=ai; if(aix2) x2=ai; return x1-x2; Visa-free policy brings Chengdu biz, tourism boost. Making national headlines several times, Chengdus 72-hour visa-free policy has attracted wide attention from both Chinese and foreign experts and businessmen since it took effect on Sept 1 last year. The program permits citizens from 51 countries and regions including the United States, Australia, Canada and Japan who have valid visas and flight tickets to a third country to spend three days in the city. The capital of Sichuan province is the first city in the western region of China to offer foreign tourists a three-day visa and the fourth nationwide to adopt the policy following Shanghai, Beijing and Guangzhou. Li Zhiyong, deputy dean of the tourism institute at Sichuan University, said the move contributes to a large increase in the number of overseas tourists and raises the citys level of internationalization. The policy will also bring direct economic revenue, Li said. Chengdu has many cultural legacies and is also a paradise for panda lovers with the worlds largest breeding and research center. Three days are long enough for foreign visitors to visit those iconic tourist spots, he noted. The city is home to the remains of the Jin sha civilization that dates back more than 3,000 years as well as the Qing cheng Mountains and the Du jiang yan irrigation system. Qing cheng has long been recognized as the birthplace of Taoism, Chinas ancient indigenous religion, while Du jiang yan is considered to be the oldest functioning water-control project in the world. Chengdu ranked third in tourist facilities, management and services among 60 Chinese cities in a customer satisfaction survey released last year. But, Li added that efforts are still needed to develop more tourism products, improve English services and provide accurate translation of traffic signs and scenic billboards. Zhao Yun, chairwoman of British Chamber of Commerce Southwest China, told China Daily that his colleagues found the policy very convenient. A British client once flew here and stayed for just one day to check her ordered goods, she said. Zhao was born in Shanxi province, but she has lived in Chengdu for more than 10 years. My life was like a running race moving from place to place. I also lived in Beijing and Shanghai before, she said. But Chengdu is a place that you never want to leave once settling down. It is now my second hometown, she said. If the environment is further improved, the city will attract more people to visit and live, with the 72-hour visa-free policy and compelling conditions in transportation, culture, climate and cuisine, he said. Foreigners also gave positive feedback on the policy. A spokesman from Dell Inc said the company has a global hub of operation in Chengdu, so the three-day visa has an immediate and positive influence on the companys business development. Rudy Buttignol, president of the public broadcasting company in British Columbia, Canada, said his work requires frequent travel to Chengdu and the policy makes the trips easier. Data from the citys public security bureau shows some 100 foreign visitors enjoyed the 72-hour policy by the end of March, most of them from the United States, the United Kingdom and Germany. Chengdu also reported robust growth in its overall tourist industry last year. Official statistics show that it received some 150 million tourists last year, an increase of 28 percent from 2012. Around 1.7 million came from abroad, an increase of 12 percent. Total revenue from tourism surpassed 133 billion yuan ($21.7billion). During his visit to Kazakhstan in September, Chinese President Xi Jinping proposed that China and Central Asia join hands to build a Silk Road economic belt to boost cooperation. The idea has been widely echoed in Central Asian countries, becoming an encouraging blueprint for Chinese areas along the Silk Road that has linked Asia and Europe for more than 2,000 years. In the next three weeks, China Daily reporters will travel through the belt in China and in Kazakhstan, Uzbekistan and Turkey. They will show the progress and expectations of the countries, businesses and peoples on the route. Shaanxi - the start of the ancient Silk Road - has positioned itself as the new starting point for the development of the Silk Road Economic Belt, which will strengthen Chinas cooperation with Central Asian countries, a senior official said. Shaanxi Governor Lou Qinjian said the province is fresh, rich and unique, as it was when it anchored one end of the ancient Silk Road. It is the best option for accommodating industrial transfers from East China or the world at large, he said on Wednesday in Xian.Lou held a joint interview with 27 media, including China Daily, the first in a series of interviews entitled Chinese Media Along the Silk Road. The interviews will be in Shaanxi and Gansu provinces and the Xinjiang Uygur autonomous region, as well as Kazakhstan, Uzbekistan and Turkey. The media group held the first interview on Wednesday morning in Xian, the starting point of the ancient Silk Road, a trade channel established more than 2,000 years ago linking China, Central Asia and Europe.
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 办公文档 > 工作计划


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!