欢迎来到天天文库
浏览记录
ID:18155842
大小:48.50 KB
页数:13页
时间:2018-09-14
《2010年12月c语言上机模拟题》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、2010年12月上机模拟题一、改错题:1、统计所有三位正整数中各个数位上的数字之和是11的数的个数。#includevoidmain(){inti,j,s,count;count=1;/*$ERROR1$*/count=0;for(i=100;i<=999;i++){s=0;j=i;while(j>1)/*$ERROR2$*/j>0{s=s+j/10;/*$ERROR3$*/j%10j=j/10;}if(s==11)count=count+1;}printf("%d",count);}2、在主函数中输入10个数存入数组,通过调用mymax()函数求数组中元素的最大
2、值并返回输出。#includeintmymax(intx[],intn){intmax,j;max=0;/*$ERROR1$*/max=x[0];for(j=1;j3、包含空格字符),统计其中不及格的人数并输出不及格学生的信息。#includegood,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosenedorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1first#includestructstudent{intn4、um;charname[20];intscore;};voidmain(){structstudentstud[5];inti,n=0;for(i=0;i<5;i++){printf("InputNO.%dnum:",i+1);scanf("%d",&stud[i].num);printf("InputNO.%dname:",i+1);scanf("%s",stud[i].name);printf("InputNO.%dscore:",i+1);scanf("%d",&stud[i].score);}printf("numtnamettscore");i=1;/*$ERROR5、1$*/i=0while(i<5){if(score<60)/*$ERROR2$*/stud[i].score{printf("%dt%-15st%d",stud[i].num,stud[i].name,stud[i].score);n--;/*$ERROR3$*/n++}i++;}printf("n=%d",n);}4、以下程序的功能为:第一个数是1,从第二个数起没个数都是它前一项的2倍再加5,求第n个数是多少(n从键盘输入且在20以内,用递归实现)。#includelongfunction(intn){longm;if(n==1)m=0;/*$ERRO6、R1$*/m=1;elsem=2*m+5;/*$ERROR2$*/m=2*function(m-1)+5return(m);good,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosenedorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1first}voidmain(){longm;int7、n;scanf("%d",n);/*$ERROR3$*/&nm=function(n);printf("%ld",m);}5、从键盘输入一字符串并删除该字符串中所有大写字母字符。#include#includevoidmain(){intn=0,i;chars[81];gets(s);i=1;/*$ERROR1$*/i=0;while(s[i]=' ')/*$ERROR2$*/s[i]!=' '{i
3、包含空格字符),统计其中不及格的人数并输出不及格学生的信息。#includegood,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosenedorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1first#includestructstudent{intn
4、um;charname[20];intscore;};voidmain(){structstudentstud[5];inti,n=0;for(i=0;i<5;i++){printf("InputNO.%dnum:",i+1);scanf("%d",&stud[i].num);printf("InputNO.%dname:",i+1);scanf("%s",stud[i].name);printf("InputNO.%dscore:",i+1);scanf("%d",&stud[i].score);}printf("numtnamettscore");i=1;/*$ERROR
5、1$*/i=0while(i<5){if(score<60)/*$ERROR2$*/stud[i].score{printf("%dt%-15st%d",stud[i].num,stud[i].name,stud[i].score);n--;/*$ERROR3$*/n++}i++;}printf("n=%d",n);}4、以下程序的功能为:第一个数是1,从第二个数起没个数都是它前一项的2倍再加5,求第n个数是多少(n从键盘输入且在20以内,用递归实现)。#includelongfunction(intn){longm;if(n==1)m=0;/*$ERRO
6、R1$*/m=1;elsem=2*m+5;/*$ERROR2$*/m=2*function(m-1)+5return(m);good,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosenedorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1first}voidmain(){longm;int
7、n;scanf("%d",n);/*$ERROR3$*/&nm=function(n);printf("%ld",m);}5、从键盘输入一字符串并删除该字符串中所有大写字母字符。#include#includevoidmain(){intn=0,i;chars[81];gets(s);i=1;/*$ERROR1$*/i=0;while(s[i]=' ')/*$ERROR2$*/s[i]!=' '{i
此文档下载收益归作者所有