电大C语言程序设计A历年考题(.1.7)缺09年7月小抄参考

上传人:1666****666 文档编号:37615978 上传时间:2021-11-03 格式:DOC 页数:8 大小:273.04KB
收藏 版权申诉 举报 下载
电大C语言程序设计A历年考题(.1.7)缺09年7月小抄参考_第1页
第1页 / 共8页
电大C语言程序设计A历年考题(.1.7)缺09年7月小抄参考_第2页
第2页 / 共8页
电大C语言程序设计A历年考题(.1.7)缺09年7月小抄参考_第3页
第3页 / 共8页
资源描述:

《电大C语言程序设计A历年考题(.1.7)缺09年7月小抄参考》由会员分享,可在线阅读,更多相关《电大C语言程序设计A历年考题(.1.7)缺09年7月小抄参考(8页珍藏版)》请在装配图网上搜索。

1、专业好文档第一套(2010年7月试题) 一、单选题(每小题2分,共20分) 1在每个C语言程序中都必须包含有这样一个函数,该函数的函数名为(A)。 A. main B. MAIN C. name D. function 2每个C语言程序文件的编译错误分为(B)类。 A. 1 B. 2 C. 3 D. 4 3. 字符串a+b=12n的长度为(B)。 A. 6 B. 7 C. 8 D. 9 4. 在switch语句的每个case块中,假定都是以break语句结束的,则此switch语句容易被改写为(D)语句。 A. for B. while C. do D. if 5. 在下面的do-while循

2、环语句中,其循环体语句被执行的次数为(C)。 int i=0; do i+; while(i5)的相反表达式为(x!=0 | y=5) 或:(x | y=5)。 6若x=5,y=10,则x!=y的逻辑值为_1(真,true)_。 7. 假定二维数组的定义为“int a35;”,则该数组所占存储空间的字节数为_60_。 8. 使用“typedef char BB1050;”语句定义_BB_为含有10行50列的二维字符数组类型。 9. 字符串a:xxkfile.txt的长度为_15_。 10假定p所指对象的值为25,p+1所指对象的值为46,则*+p的值为_46_。 11. 假定一个数据对象为in

3、t*类型,则指向该对象的指针类型为_int*_。 12假定一个结构类型的定义为 “struct Aint a,b; A* c;”,则该类型的理论长度为_12_。 13. 假定要访问一个结构对象x中的数据成员a,则表示方式为_x.a_。 三、写出下列每个程序运行后的输出结果(每小题6分,共30分) 1. #include void main() int i,j,k=0; for(i=0; i5; i+) for(j=i; j5; j+) k+; printf(%dn,k); 运行结果:15 2. #include void main() int x=20; int i=2; while(ix)

4、if(x%i=0) printf(%d ,i); x/=i; i+; 运行结果:2 5 3. #include void main() int a8=70,63,54,95,40,75,90,66; int i, s=0; for(i=0; i=70 & ai=90) s+=ai; printf(s=%dn,s); 运行结果:s=235 4. #include int WF(int x, int y) x=x+y; y+=x; return x+y; void main() int x=3, y=5; printf(%dn,WF(x,y); 运行结果: 21 5. #include int L

5、A(int *a, int n) int i,s=0; for(i=0;in;i+) s+=ai; return s; void main() int a5=1,2,3,4,5; int b=LA(a,5)+LA(a+1,3); printf(b=%dn,b); 运行结果: b=24 四、写出下列每个函数的功能(每小题6分,共12分) 1. int SG(int x) /x为大于等于2的整数 int i=2; if(x=2 | x=3) return 1; while(i*i=x) if(x%i=0) break; i+; if(i*idata; f=f-next; while(f) if(f

6、-datax) x=f-data; f=f-next; return x; 假定struct IntNode的结点类型定义为: struct IntNode int data; struct IntNode* next;函数功能:求出并返回由f所指向的单链表中所有结点的最大值。 五、按照题目要求编写程序或函数(每小题6分,共12分) 1. 编写一个主函数,计算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*

7、=3; s+=p; printf(%dn,s); 2. 根据函数原型“int FF(int a, int n)”,编写函数定义,计算并返回数组an中所有元素之和。程序为:int FF(int a, int n) int i,sum=0; for(i=0; i0 & x=10)的相反表达式为(A)。 Ax10 Bx10 Cx=0 | x0 & x10 3当处理特定问题时的循环次数已知时,通常采用(A)循环来解决。 Afor Bwhile Cdo-while Dswitch 4假定i的初值为0,则在循环语句“while(iscore 。三、写出下列每个程序运行后的输出结果 1. #include

8、void main() int x=5; switch(2*x-1) case 4: printf(%d ,x); break; case 7: printf(%d ,2*x); break; case 10: printf(%d ,3*x); break; default: printf(%s ,default); printf(%sn,switch end.); 运行结果:default switch end. 2. #include void main() int f1,f2,i; f1=1; printf(%d ,f1); for(i=2;i=5;i+) f2=3*f1+1; prin

9、tf(%d ,f2); f1=f2; printf(n); 运行结果: 1 4 13 40 121 3. #include void main() int a10=12,39,26,41,55,63,72,40,83,95; int i, i1=0, i2=0; for(i=0;i10;i+) if(ai%2=1) i1+; else i2+; printf(%d %dn,i1,i2); 运行结果:6 4 4. #include #include void main( ) char s15=567891234; int i, n=strlen(s) ; for(i=0; in/2; i+) c

10、har c=si; si=sn-1-i; sn-1-i=c; printf(%sn,s); 运行结果:432198765 5. #include int LB(int *a, int n) int i,s=1; for(i=0;in;i+) s*=*a+; return s; void main() int a=1,2,3,4,2,4,5,2; int b=LB(a,4)+LB(a+3,3); printf(b=%dn,b); 运行结果: b=566. #include void main() int i, s=0; for(i=1;i+) if(s30) break; if(i%2=0) s

11、+=i; printf(s=%dn,s); 运行结果:s=42 7. #include void main() int a9=36,25,48,24,55,40,18,66,20; int i, b1, b2; b1=b2=a0; for(i=1; ib1) b1=ai; if(aib2) b2=ai; printf(%d %dn,b1,b2); 运行结果:66 18 8. #include void SB(char ch) switch(ch) case A: case a: printf(WW ); break; case B: case b: printf(GG ); break; de

12、fault: printf(BB ); break; void main() char a1=a,a2=B,a3=f; SB(a1);SB(a2);SB(a3); printf(n); 运行结果:WW GG BB 9. #include #define M 6 void main() int i,x; int aM=10,15,22,37,46,58; for(i=0; iM/2; i+) x=ai; ai=aM-1-i; aM-1-i=x; for(i=0; i6; i+) printf(%d ,ai); printf(n); 运行结果:58 46 37 22 15 10 10. #incl

13、ude struct Worker char name15; int age; float pay; ; void main() struct Worker x=wanghua,52,2350; struct Worker y, *p; y=x; p=&x; printf(%d %7.2fn, y.age+p-age, p-pay+20); 运行结果:104 2370.00 五、按题目要求编写程序或函数1. 编写一个程序,输出50以内(含50)的、能够被3或者5整除的所有整数。程序为:#include void main() int i; for(i=3; i=50; i+) if(i%3=0

14、 | i%5=0) printf(%d ,i); printf(n); 2. 编写一个递归函数“int FF(int a, int n)”,求出数组a中所有n个元素之积并返回。程序为: int FF(int a, int n) if(ny的值为0(假)。 7. 假定二维数组的定义为“int a35;”,则该数组所含元素的个数为15 。 8. 执行“typedef int ABC10;”语句把ABC定义为具有10个整型元素的_数组_类型。 9. strcat()函数用于连接两个字符串。 10假定p所指对象的值为25,p+1所指对象的值为46,则*p+的值为 25 。 11. 若要把一个整型指针p

15、转换为字符指针,则采用的强制转换表达式为(char*)p 。 12. NULL是一个符号常量,通常作为空指针值,它对应的值为 0 。 13. 假定要动态分配一个类型为struct Worker的对象,并由r指针指向这个对象,则使用的表达式为 struct Worker* r =malloc(sizeof(struct Worker)。三、写出下列每个程序运行后的输出结果(每小题6分,共30分) 1. #include void main() int i,s=0; for(i=1;i6;i+) s+=i*i; printf(“s=%dn”,s); 运行结果: s=55 2. #include #

16、define N 6 void main() int i,aN=2,5,8,10,15,21; for(i=0; iN; i+) if(ai%5) printf(%d ,ai); printf(n); 运行结果: 2 8 21 3. #include #include void main() int i; unsigned int len; char* a5=student,worker,cadre,soldier,zzeasan123; len=strlen(a0); for(i=1; ilen) len=strlen(ai); printf(%dn,len); 运行结果:10 4. #in

17、clude void main() int a,b; for(a=2,b=3; b20;) printf(%d %d ,a,b); a=a+b; b=a+b; printf(%d %dn,a,b); 运行结果:2 3 5 8 13 21 5. #include void LE(int* a, int* b) int x=*a; *a=*b; *b=x; void main() int x=15, y=26; printf(%d %dn,x,y); LE(&x,&y); printf(%d %dn,x,y); 运行结果:15 26 26 15五、按题目要求编写程序或函数(每小题6分,共12分)

18、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个元素之积并返回。 2. 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); 第四套(2009年1月试题)

19、 一、单选题(每小题2分,共20分) 1. 由C语言目标文件连接而成的可执行文件的缺省扩展名为(B)。 A. cpp B. exe C. obj D. c 2. 设有两条语句为“int a=12; a+=a*a;”,则执行结束后,a的值为(C)。 A. 12 B. 144 C. 156 D. 288 3. 带有随机函数调用的表达式rand()%20的值在(C)区间内。 A. 119 B. 120 C. 019 D. 020 4. for循环语句“for(i=0; in; i+=2) S;”中循环体S语句被执行的次数为(A)。 A. (n+1)/2 B. n/2+1 C. n/2-1 D. n-

20、1 5. 在下列的字符数组定义中,存在语法错误的是(D)。 A. char a20=abcdefg; B. char a=x+y=55.; C. char a15=1,2; D. char a10=5; 6. 若有一个函数原型为“double *function()”,则它的返回值类型为(B)。 A. 实数型 B. 实数指针型 C. 函数指针型 D. 数组型 7. 在C语言中,所有预处理命令都是以(B)符号开头的。(B) A. * B. # C. & D. 8. 假定整数指针p所指数据单元的值为30,p+1所指数据单元的值为40,则执行*p+后,p所指数据单元的值为(A)。 A. 40 B.

21、30 C. 70 D. 10 9. 若要使p指向二维整型数组a1020,则p的类型为(D)。 A. int * B. int * C. int *20 D. int(*)20 10. 表示文件结束符的符号常量为(C) A. eof B. Eof C. EOF D. feof二、填空题(每小题2分,共26分) 1一个函数定义由 函数头_和函数体两部分组成。 2. 执行“printf(%c,F-2);”语句后得到的输出结果为 D 。 3int类型的长度为 4 。 4. 表达式(float)25/4的值为 6.25 。 5若x=5,y=10,则x=y的逻辑值为 1(或真) 。 6. 作为语句标号使用

22、的case和default只能用于 switch 或开关 或分情况_语句的定义体中。 7. 在程序中执行到 return 或返回 语句时,将结束所在函数的执行过程,返回到调用该函数的位置。 8. 假定二维数组的定义为“char aMN;”,则该数组所含元素的个数为 M*N 。 9. 存储字符a需要占用存储器的_1_个字节空间。 10. 用于存储一个长度为n的字符串的字符数组的长度至少为_n+1_。 11. 假定p所指对象的值为25,p+1所指对象的值为46,则执行表达式(*p)+后,p所指对象的值为_26_。 12. 假定p是一个指向整数对象的指针,则用 *p 表示该整数对象。 13假定一个结

23、构类型的定义为“struct Bint a5; char* b;”,则该类型的理论长度为_24_。三、写出下列每个程序运行后的输出结果(每小题6分,共30分) 1. #include void main() int i, s1=0, s2=0; for(i=0;i10;i+) if(i%2) s1+=i; else s2+=i; printf(%d %dn,s1,s2); 运行结果: 25 20 2. #include const int M=20; void main() int i=2; while(1) if(iM/2) break; if(M%i=0) printf(%d ,i); i

24、+; printf(n); 运行结果: 2 4 5 10 3. #include int a6=4,5,6,15,20,12; void main() int i,s1,s2; s1=s2=0; for(i=0; i6; i+) switch(ai%2) case 0: s2+=ai;break; case 1: s1+=ai;break; printf(%d %dn,s1,s2); 运行结果:20 42 4. #include void main() int a33=3,5,7,9,11,13,6,8,20; int i,*p=&a00; for(i=0;i10) printf(%d ,*p

25、); p+; printf(n); 运行结果:11 13 20 5. #include #include struct Worker char name15; int age; float pay; void main() struct Worker x; char *t=liouting; int d=38; float f=400; strcpy(x.name,t); x.age=d; x.pay=f; x.age+; x.pay*=2; printf(%s %d %6.2fn,x.name,x.age,x.pay); 运行结果: liouting 39 800.00四、写出下列每个函数的

26、功能(每小题6分,共12分) 1. #include int SA(int a, int b) if(ab) return 1; else if(a=b) return 0; else return -1; 函数功能:比较两个整数a和b的大小,若ab则返回1,若a=b则返回0,若adata); f=f-next; printf(n); 假定struct IntNode的类型定义为: struct IntNode int data; struct IntNode* next;函数功能:遍历并输出由f所指向的单链表中每个结点的值。五、按题目要求编写程序或函数(每小题6分,共12分)1. 编写一个程

27、序,计算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); 2. 根据函数原型“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; Winger Tuivasa-Sheck

28、, who scored two tries in the Kiwis 20-18 semi-final win over England, has been passed fit after a lower-leg injury, while Slater has been named at full-back but is still recovering from a knee injury aggravated against USA.Both sides boast 100% records heading into the encounter but Australia have

29、not conceded a try since Josh Charnleys effort in their first pool match against England on the opening day.Aussie winger Jarryd Hayne is the competitions top try scorer with nine, closely followed by Tuivasa-Sheck with eight.But it is recently named Rugby League International Federation player of t

30、he year Sonny Bill Williams who has attracted the most interest in the tournament so far.The Kiwi - with a tournament high 17 offloads - has the chance of becoming the first player to win the World Cup in both rugby league and rugby union after triumphing with the All Blacks in 2011.Id give every aw

31、ard back in a heartbeat just to get across the line this weekend, said Williams.The (lack of) air up there Watch mCayman Islands-based Webb, the head of Fifas anti-racism taskforce, is in London for the Football Associations 150th anniversary celebrations and will attend Citys Premier League match a

32、t Chelsea on Sunday.I am going to be at the match tomorrow and I have asked to meet Yaya Toure, he told BBC Sport.For me its about how he felt and I would like to speak to him first to find out what his experience was.Uefa hasopened disciplinary proceedings against CSKAfor the racist behaviour of th

33、eir fans duringCitys 2-1 win.Michel Platini, president of European footballs governing body, has also ordered an immediate investigation into the referees actions.CSKA said they were surprised and disappointed by Toures complaint. In a statement the Russian side added: We found no racist insults fro

34、m fans of CSKA. Baumgartner the disappointing news: Mission aborted.The supersonic descent could happen as early as Sunda.The weather plays an important role in this mission. Starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather l

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

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


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