中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc

上传人:文库蛋蛋多 文档编号:4126057 上传时间:2023-04-06 格式:DOC 页数:11 大小:121KB
返回 下载 相关 举报
中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc_第1页
第1页 / 共11页
中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc_第2页
第2页 / 共11页
中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc_第3页
第3页 / 共11页
中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc_第4页
第4页 / 共11页
中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc》由会员分享,可在线阅读,更多相关《中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc(11页珍藏版)》请在三一办公上搜索。

1、2012春电大C语言程序设计模拟试题及解答一、选择题 1. 由C语言源程序文件编译而成的目标文件的缺省扩展名为( C )。 A. cpp B. exe C. obj D. C 2. C语言程序的基本模块为( D )。 A. 表达式 B. 标识符 C. 语句 D. 函数 3. 设x和y均为逻辑值,则x|y为假的条件是( C )。 A它们均为真 B.其中一个为真 C.它们均为假 D.其中一个为假 4. x0 | y=5的相反表达式为( B )。A. x=0 | y!=5 B. x0 | y!=5 D. x0 & y=5 5. 枚举类型中的每个枚举常量的值都是一个( A )。 A. 整数 B. 浮点

2、数 C. 字符 D. 逻辑值6. 循环体至少被执行一次的语句为( C )循环语句。 Afor B.while C.do-while D.任一种 7. 循环语句“for(int i=0; in; i+) S;”中循环体S被执行的次数为( C )。 A. 1 B. n-1 C. n D. n+1 8. 在下面的while循环语句中,其循环体被执行的次数为( C )。 int i=0,s=0; while(s3 & x10的相反表达式为 x=10 。 17若x=5,y=10,则x!=y的逻辑值为 1 。 18. 假定x=5,则执行“int a=(! X? 10:20);”语句后a的值为 20 。19

3、. 在if语句中,每个else关键字与它前面同层次并且最接近的 if 关键字相配套。 20. 若while循环的“头”为“while(i+name等价的表达式是 (*p).name 。三、写出下列每个程序运行后的输出结果 1. #include void main() int i, s=0; for(i=1;i+) if(s50) break; if(i%2=0) s+=i; printf(i,s=%d, %dn,i,s); 结果:i,s=15,56 2. #include void main() 结果* char ch=*; int i, n=5; while(1) for(i=0;in;i

4、+) printf(%c,ch); printf(n); if(-n=0) break; 3. #includeconst int N=5;void main()结果 1 1 1 2 2 2 3 6 9 4 24 33 int i,p=1,s=0; for(i=1;iN;i+) p=p*i; s=s+p; printf(%5d%5d,i,p); printf(%5dn,s); 4. #include void main() int x=24,y=88; int i=2,p=1; do while(x%i=0 & y%i=0) p*=i; x/=i; y/=i; i+; while(x=i &

5、y=i); printf(%dn,p*x*y); 结果:p*x*y=8*3*11=264 5. #include void main() int a9=36,25,48,24,55,40,18,66,20; int i, b1, b2; a0=a1? (b1=a0, b2=a1):(b1=a1,b2=a0); for(i=2; i9; i+) if(aib1) b2=b1; b1=ai; else if(aib2) b2=ai; printf(%d %dn,b1,b2); 结果:18 20 6. #include void main() int a12=76,63,54,62,40,75,80

6、,92,77,84,44,73; int b4=60,70,90,101; int c4=0; int i,j; for(i=0;i=bj) j+; cj+; for(i=0;i4;i+) printf(%d,ci); printf(n); 结果:3 2 6 17. #include void main() int a=10, b=20;结果 10 20 40 35 40 20 printf(%d %dn,a,b); int b=a+25; a*=4; printf(%d %dn,a,b); printf(%d %dn,a,b); 8. #include void SelectSort(int

7、 a, int n) int i,j,k,x; for(i=1;in;i+) /进行n-1次选择和交换 k=i-1; for(j=i;jn;j+) if(ajak) k=j; x=ai-1; ai-1=ak; ak=x; void main() int i; int a6=20,15,32,47,36,28; SelectSort(a,6); for(i=0; i6; i+) printf(%d ,ai); printf(n); 结果:15 20 28 32 36 47 9#include void main() int a8=4,8,12,16,20,24,28,32; int *p=a;

8、do printf(%d,*p); p+=2; while(pa+8); printf(n); 结果:4 12 20 28 10. #include void LE(int* a, int* b) int x=*a; *a=*b; *b=x; 结果15 26 26 15 void main() int x=15, y=26; printf(%d %dn,x,y); LE(&x,&y); printf(%d %dn,x,y); 11. #include #include struct Worker char name15; /姓名 int age; /年龄 float pay; /工资 ; in

9、t Equal(struct Worker* r1, struct Worker* r2) if(strcmp(r1-name, r2-name)=0) return 1; else return 0; void main() struct Worker a4=abc,25,420,defa,58,638, ghin,49,560,jklt,36,375; struct Worker x=defa; int i; for(i=0; i=4) printf(没有查找所需要的记录!n); else printf(%s %d %6.2fn,ai.name,ai.age,ai.pay); 结果:def

10、a 58 638.00四、写出下列每个函数的功能 1. int SE(int n) /n为大于等于1的整数 int x,s=0; printf(输入%d个整数: ,n); scanf(%d,&x); if(n=1) return x; s=x; while(-n) scanf(%d,&x); s+=x; return s; 函数功能:求出键盘上输入的n个整数之和并返回。2. float FH() float x,y=0,n=0;scanf(%f,%x);while(x! =-1.0) n+; y+=x;scanf(%f,%x);if(n-0) return y; else return y/n

11、; 函数功能:求出从键盘上输出的一批常数的平均值,以-1.0作为结束输入的标志。 3. #include void WA(int a, int n) int i,k,j,x; for(i=0;in-1;i+) k=i; for(j=i+1;jak) k=j; x=ai; ai=ak; ak=x; 函数功能:采用选择排序的方法对数组a中的n个整数按照从大到小的次序重新排列。 4. #include int* LJ(int a, int n) int i,k=0; for(i=1;iak) k=i; return &ak; 函数功能:求出数组a中n个元素的最大值元素,返回该元素的地址。 5. vo

12、id QC(struct StrNode* f) while(f) printf(%sn,f-name);f=f-next; 假定结构类型StrNode的定义如下: stuct StrNode char name15; /字符串域 struct StrNode *next; /指针域 ; 函数功能:遍历f单链表,即从头结点开始依次输出f单链表中每个结点的值。待添加的隐藏文字内容3 6. int Output(struct IntNode *f) int sum=0; if(!f) return -9999; /用返回特定值-9999表示空表 while(f) sum+=f-data; f=f-

13、next; return sum; 假定struct IntNode的类型定义为: struct IntNode int data; /结点值域 struct IntNode* next; /结点指针域 ; 函数功能:对于以表头指针为f的链表,求出并返回所有结点中data域的值之和。 7. int wr4(FILE* fptr) char ch; int c=0; fseek(fptr,0,SEEK_SET); while(1) ch=fgetc(fptr); if(ch!=EOF) c+; else break; return c; 函数功能:求出一个以fptr为文件流的所对应文件的长度,即

14、所存字符的个数。五、根据下列每个题目要求编写程序1. 编写一个函数fun(),首先从键盘上输入一个4行4列的一个实数矩阵到一个二维数组a44中,接着求出主对角线上元素之和,最后返回求和结果。 #include double fun() double a44; double s=0; int i,j; printf(输入一个4*4的数值矩阵:n); for(i=0;i4;i+) for(j=0;j4;j+) scanf(%lf,&aij); for(i=0;i4;i+) s+=aii;i return s; void main() printf(主对角线上元素之和是%lfn,fun(); 2.

15、编写一个主函数,计算1+3+32+.+310的值并输出,假定分别用i,p,s作为循环变量、累乘变量和累加变量的标识符。#include void main() int i; /用i作为循环变量 int p=1; /用p作为累乘变量 int s=1; /用s作为累加循环变量 for(i=1;i=10;i+) p*=3; s+=p; printf(%dn,s); 3. 编写一个主函数,已知6a40,15b30,求出满足不定方程2a+5b=120的全部整数组解。如(13,20)就是其中的一组解。#include void main() int a,b; for(a=6;a=40; a+) for(b

16、=15;b=30;b+) if(2*a+5*b=126) printf(%d, %d)n,a,b); If we dont do that it will go on and go on. We have to stop it; we need the courage to do it.His comments came hours after Fifa vice-president Jeffrey Webb - also in London for the FAs celebrations - said he wanted to meet Ivory Coast international

17、Toure to discuss his complaint.CSKA general director Roman Babaev says the matter has been exaggerated by the Ivorian and the British media.Blatter, 77, said: It has been decided by the Fifa congress that it is a nonsense for racism to be dealt with with fines. You can always find money from somebod

18、y to pay them.It is a nonsense to have matches played without spectators because it is against the spirit of football and against the visiting team. It is all nonsense.We can do something better to fight racism and discrimination.This is one of the villains we have today in our game. But it is only

19、with harsh sanctions that racism and discrimination can be washed out of football.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

20、 at 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

21、their 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 f

22、rom 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 limit

23、ed cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial

24、airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.The balloon will slowly drift to the edge of space at 120,000 feet ( Then, I would assume, he will slowly step out onto something resembling an O

25、lympic diving platform.Below, the Earth becomes the concrete bottom of a swimming pool that he wants to land on, but not too hard. Still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. It will be like he is diving into the shallow end.Skydive

26、r preps for the big jumpWhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to stop him completely.If he go

27、es too fast or spins out of control, he has a stabilization parachute that can be deployed to slow him down. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).In order to deploy this chute successfully, he will have to slow to 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if ever

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 办公文档 > 其他范文


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号