c语言程序设计历年考题,本科《C语言程序设计A》历年考题汇总

《本科《C语言程序设计A》历年考题汇总》由会员分享,可在线阅读,更多相关《本科《C语言程序设计A》历年考题汇总(7页珍藏版)》请在人人文库网上搜索。

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

2、的次数为(C)。int i=0; do i+; while(i5)的相反表达式为(x!=0 | yvoid main() int i,j,k=0;for(i=0; ivoid main() int x=20;int i=2;while(ivoid main() int a8=70,63,54,95,40,75,90,66;int i, s=0;for(i=0; i=70 & aiint 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); 运行结果: 215. #includei。

3、nt LA(int *a, int n) int i,s=0;for(i=0;idata;f=f-next;while(f) if(f-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作为循环变量、累乘变量和累加变量的标识符。程序为:#in。

4、cludevoid main()int i; int p=1; int s=1; for(i=1;i0 & x10 Bx10Cx0 & x103当处理特定问题时的循环次数已知时,通常采用(A)循环来解决。Afor Bwhile Cdo-while Dswitch4假定i的初值为0,则在循环语句“while(iscore 。三、写出下列每个程序运行后的输出结果1. #includevoid main() int x=5;switch(2*x-1) case 4: printf(%d ,x); break;case 7: printf(%d ,2*x); break;case 10: printf。

5、(%d ,3*x); break;default: printf(%s ,default); printf(%sn,switch end.); 运行结果:default switch end.2. #includevoid main() int f1,f2,i;f1=1;printf(%d ,f1);for(i=2;ivoid main() int a10=12,39,26,41,55,63,72,40,83,95;int i, i1=0, i2=0;for(i=0;i#includevoid main( ) char s15=567891234;int i, n=strlen(s) ;for。

6、(i=0; iint LB(int *a, int n) int i,s=1;for(i=0;ivoid main() int i, s=0;for(i=1;i+) if(s30) break;if(i%2=0) s+=i; printf(s=%dn,s); 运行结果:s=427. #includevoid 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(aivoid SB(char ch) switch(ch) case A: case a:printf(WW ); 。

7、break;case B: case b:printf(GG ); break;default:printf(BB ); break; void main() char a1=a,a2=B,a3=f;SB(a1);SB(a2);SB(a3);printf(n); 运行结果:WW GG BB9. #include#define M 6void main() int i,x;int aM=10,15,22,37,46,58;for(i=0; istruct Worker char name15; int age; float pay; ;void main() struct Worker x=wa。

8、nghua,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; iy的值为0(假)。 7. 假定二维数组的定义为“int a35;”,则该数组所含元素的个数为15 。8. 执行“typedef int ABC10;”语句把ABC定义为具有10个整型元素的_数组_类型。9. 。

9、strcat()函数用于连接两个字符串。10假定p所指对象的值为25,p+1所指对象的值为46,则*p+的值为 25 。11. 若要把一个整型指针p转换为字符指针,则采用的强制转换表达式为(char*)p 。12. NULL是一个符号常量,通常作为空指针值,它对应的值为 0 。13. 假定要动态分配一个类型为struct Worker的对象,并由r指针指向这个对象,则使用的表达式为 struct Worker* r =malloc(sizeof(struct Worker)。三、写出下列每个程序运行后的输出结果(每小题6分,共30分)1. #includevoid main() int i,s。

10、=0;for(i=1;i#define N 6void main() int i,aN=2,5,8,10,15,21;for(i=0; i#includevoid 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); 运行结果:104. #includevoid main() int a,b;for(a=2,b=3; bvoid LE(int* a, int* b) i。

11、nt 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 2626 15五、按题目要求编写程序或函数(每小题6分,共12分)1. 编写一个程序,输出50以内(含50)的、能够被3或者5整除的所有整数。#include void main() int i; for(i=3; ivoid main() int i, s1=0, s2=0;for(i=0;iconst int M=20;void main() int i=2;while(1) if。

12、(iM/2) break;if(M%i=0) printf(%d ,i);i+; printf(n); 运行结果: 2 4 5 103. #includeint a6=4,5,6,15,20,12;void main() int i,s1,s2;s1=s2=0;for(i=0; ivoid main() int a33=3,5,7,9,11,13,6,8,20;int i,*p=&a00;for(i=0;i10) printf(%d ,*p);p+; printf(n); 运行结果:11 13 205. #include#includestruct Worker char name15; in。

13、t 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四、写出下列每个函数的功能(每小题6分,共12分)1. #includeint SA(int a, int b) if(ab) return 1;else if(a=b) return 0;else 。

14、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. 编写一个程序,计算1+3+32+.+310的值并输出,假定分别用i,p,s作为循环变量、累乘变量和累加变量的标识符。程序为:#includevoid main()int i; int p=1; int。

15、 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; Emloyment tribunals sort out disagreements between employers and employees. You may need to make a claim to an employm。

16、ent tribunal if: you dont agree with the disciplinary action your employer has taken against you your employer dismisses you and you think that you have been dismissed unfairly. For more informu, take advice from one of the organisations listed underFur ther help. Employment tribunals are less forma。

17、l than some other courts, but it is still a legal process and you will need to give evidence under an oath or affirmation. Most people find making a claim to an employment tribunal challenging. If you are thinking about making a claim to an employment tribunal, you should get help straight away from。

18、 one of the organisations listed underFurther help. ation about dismissal and unfair dismissal, seeDismissal. You can make a claim to an employment tribunal, even if you haventappealedagainst the disciplinary action your employer has taken against you. However, if you win your case, the tribunal may。

19、 reduce any compensation awarded to you as a result of your failure to appeal. Remember that in most cases you must make an application to an employment tribunal within three months of the date when the event you are complaining about happened. If your application is received after this time limit, 。

20、the tribunal will not usually accept i. If you are worried about how the time limits apply to you If you are being represented by a solicitor at the tribunal, they may ask you to sign an agreement where you pay their fee out of your compensation if you win the case. This is known as adamages-based a。

21、greement. In England and Wales, your solicitor cant charge you more than 35% of your compensationif you win the case. You are clear about the terms of the agreement. It might be best to get advice from an experienced adviser, for example, at a Citizens Advice Bureau. To find your nearest CAB, includ。

22、ing those that give advice by e-mail, click onnearest CAB. For more information about making a claim to an employment tribunal, seeEmployment tribunals. The (lack of) air up there Watch m Cay man 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 at Chelsea on。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值