c语言程序改错填空解析题库,C语言机试改错、填空题.doc

C语言机试改错、填空题.doc

一.输入小于2012的十个最大的素数include stdio.hvoid main int i,j,flag,n; n0; i2012; whilen10 /*ERROR1*/ flag0; forj2;ji;j ifi/j0 /*ERROR2*/ flag1; break; ifflag0 /*ERROR3*/ nn1; printfdn,i; ii-1; 二、将在字符串t中而未在字符串s中的字符顺序存储的新的字符串u中include stdio.hincludestring.hvoid mainchar s8012345,t802468,u80;int i,j,p,len1,len2;p; /*BLANK1*/len1strlent;len2strlens;fori0;ilen1;iforj0;jlen2;jiftisj break; if jlen2 up; /*BLANK2*/p;up; /*BLANK3*/printfsn,u;一.1. while(n10)2. ifij 03. ifflag 0二、1、02、ti3、0一、输出图形 121 321 4321 54321include stdio.hvoid mainint i,j;i1; whilei6 forj1;j6-i;jprintf ;j1; /*ERROR1*/ whilej1 printfd,i; /*ERROR2*/ j;printf/n; /*ERROR3*/i; 二、计算并输出级数的前N项之和SN,直到SN大于q为止,q的值通过形参传入SN2/13/24/3N1/N若q6,则函数值为6.083333include stdio.hfloat sumfloat qint N1;float SN0;whileSNq /*BLANK1*/SNSN1.0*N1/N;; /*BLANK2*/return SN;void mainfloat q;printf q;scanff,q;printffn,_; /*BLANK3*/一、 jiprintf“d”,jprintf“n”二、N或NSumq一、输入5名学生4门课的成绩,输出每门课的最高分include stdio.hdefine N 4define M 5void main int i, j;float score, firstscore,max;fori1;iM;iprintfn Please score of course no d,i;scanff, firstscore ;/*ERROR1*/max firstscore;/*ERROR2*/forj2;jN; j scanff , score;ifscoremax score max;/*ERROR3*/printfn The max score of course no d is f, i, max;二、Fun的功能是计算正整数n的所有因子(1和n除外)之和作为函数值的返回。N120,函数值239include stdio.hint funint nint i,sum0;fori2;i_;i /*BLANK1*/if_ sumsumi; /*BLANK2*/return sum; void mainint n;printf n;scanfd,n;printfdn,_; /*BLANK3*/一、scanf“f”,firstscoremaxfirstscoremaxscore二、 nni 0funn一、输出一维数组中最大元素及其下标值include stdio.hint getMaxFromArrayint a,int n int i,max;max1; /*ERROR1*/fori1;in;iifai amaxmaxi; return i; /*ERROR2*/void mainint a1013,1,-5,4,9,0,-8,7,-6,2;int max;max getMaxFromArraya; /*ERROR3*/printfmaxd,addressdn,amax,max;二、将每个单词的开头字母改成大写include stdio.hvoid mainchar str80,*ch;int flag1;printfPlease a stringn;getsstr;ch; /*BLANK1*/while*chif *ch flag1;elseif flag *cha *chz /*BLANK2*/*ch*ch-32;flag0; ; /*BLANK3*/printfsn,str;一、 max0return maxmaxgetMaxArraya,10二、str1ch一、计算112123.123ninclude stdio.hint sumint n int i,s; s1; /*ERROR1*/ fori1;in;i ssi; return s;void main int i,n; long s; printfnPlease n; scanfd,n; /*ERROR2*/ s0; fori1;in;i s sumi; /*ERROR3*/ printfnThe result is ldn,s; 二、fun的功能找出100到999之间三位数之和等于9的所有整数,并放入s所指数组中,个数通过n传回。include stdio.hvoid funint s,int *nint a,b,c,i;fori100;i999;ia; /*BLANK1*/bi/1010;ci10;ifabc9s*ni; ; /*BLANK2*/ void mainint s50,n0,i;fun_; /*BLANK3*/fori0;in;iprintfd ,si;printfn; 一、 s0scanf“d”,nsssumi二、i/100 (*n)S,n一、统计罚分达到或超过12的车总数并输出这些车辆信息include stdio.hstruct car char id12; int scorevoid main int i,n0; car c6 A-QQ111,8, /*ERROR1*/ A-TT222,12, B-WJ333,12, C-LC444,5, F-PC555,6, B-MY666,12; printfidtscoren; i0; whilei6 ifscore12 /*ERROR2*/ printfstdn,ci.id,ci.score; n; /*ERROR3*/ i; printfndn,n;二、统计字符串s中元音字母的个数include stdio.hinclude ctype.hvoid mainchar s80;int i0,a50;printfPlease a stringn;gets; /*BLANK1*/whilesi_ /*BLANK2*/switchtouppersi case Aa0;break; case Ea1;break; case Ia2;break; case Oa3;break; case Ua4;break;; /*BLANK3*/fori0;i5;iprintfd ,ai; printfn;一、 struct car c6“A-QQ111”,8ifci.score12n二、 s0i一、数列第一、二项都是1,从第三项开始都是前两项之和,求第n项(n从键盘输入,用递归)include stdio.hlong fint n ifn1 n2 /*ERROR1*/ return 1; else return fn-1 - fn-2; /*ERROR2*/void main long m; int n; printfnPlease nn; scanfd,n; /*ERROR3*/ ifn0 mfn; printfldn,m; else printfData errorn;二、fun功能删除字符串中的数字include stdio.hinclude string.hvoid funchar sint i,j;fori0,j0;si_;i /*BLANK1*/ifsi0 si9sjsi;sj; /*BLANK2*/void mainchar str80;printf a stringn;gets_; /*BLANK3*/funstr;putsstr;一、 ifn 1n 2return fn-1fn-2scanf“d”,n二、00str一、将一个数组的数据逆序输出include stdio.hint sortint a,int lenthint i,t;iflenth0return -1;fori0;ilenth/2;ita0;/*ERROR1*/aialenth-i-1;alenth-i-1t;return 1;/*ERROR2*/void mainint a101,2,3,4,5,6,7,8,9,10;int i,nReturn;printfn The ascending array is n;fori0;i10;iprintf4d,ai;nReturnsort10;/*ERROR3*/ifnReturn0printfn The descending array is n;fori0;i10;iprintf4d,ai;printfn;elseprintferrorn;二、将数组中的数按从小到大排序后输出include stdio.hvoid mainint a1034,-5,12,50,88,62,1,-70,-20,0;int i,j,temp;for i0;i9;iforj0;j9-i;jif _ /*BLANK1*/temp aj; aj aj1;aj1_; /*BLANK2*/fori0;i9;i printf5d,_; /*BLANK3*/ printfn;一、 taireturn 0nReturnsorta,10二、 ajaj1tempai一、判断字符串是否对称include stdio.hint funchar s int left,right;leftright0;while sright0 right;forright;leftright ;left,rightifsleft sright /*ERROR1*/break; return right-left;void main char str100;int flag;printfPlease string;getsstr;flagfun;/*ERROR2*/if flag0/*ERROR3*/printfNo.n;else printfYes.n;二、递归调用函数printstring,将输入的字符串s中字符以相反顺序输出include stdio.hinclude string.hvoid printstringchar s,int nprintfc,_; /*BLANK1*/ifn1printfn;elseprintstring; /*BLANK2*/void mainint n;char s80;printfPlease a stringn;gets; /*BLANK3*/nstrlens; printstrings,n;一、 ifsleftsrightflagfunstrif flag0二、sn-1s,n-1s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值