您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 商业计划书 > C语言程序填空题及答案
程序填空题1、#includestdio.hvoidmain(){intn,k=0;scanf(%d,&n);while(_____1_____)//1)n2)n!=0;{k++;_____2_____;n=n/10}printf(%d\n,k);}2、#includestdio.h#includemath.h#definef(x)x*x-5*x+sin(x)voidmain(){intx;floatmax;______1______//max=f(1);for(x=2;x=10;x++)______2______//if(f(i)max)max=f(i);printf(%f\n,max);}3、#includestdio.hvoidmain(){charc;c=getchar();if(______1______)//c='a'&&c'v'c=c+5;elseif(c='v'&&c='z')______2______//c=c-21;putchar(c);}4、#includestdio.hvoidDec2Bin(intm){intbin[32],j;for(j=0;m!=0;j++){bin[j]=______1______;//m%2m=m/2;}for(;j!=0;j--)printf(%d,______2______);//bin[j-1]}voidmain(){intn;scanf(%d,&n);Dec2Bin(n);}5、#includestdio.h#includemath.hvoidmain(){intn,s=0;scanf(%d,&n);______1______//n=(n0?n:-n);2)n=fabs(n);while(n!=0){______2______//s=s+n%10;n=n/10;}printf(%d\n,s);}6、/#includestdio.hvoidswap(______1______)//int*pa,int*pb{/*交换两个数的位置*/inttemp;temp=*pa;*pa=*pb;*pb=temp;}voidmain(){inta,b,c,temp;scanf(%d%d%d,&a,&b,&c);if(ab)swap(&a,&b);if(bc)swap(&b,&c);if(______2______)//abswap(&a,&b);printf(%d,%d,%d,a,b,c);}7、#includestdio.h_______1______//longf(intn);voidmain(){printf(%ld\n,f(30));}longf(intn){if(______2______)//n==1||n==2return1;elsereturnf(n-1)+f(n-2);}8、#includestdio.hvoidmain(){chars[80];inti,j;gets(s);for(i=j=0;______1______;i++)//s[i]!=’\0’if(s[i]!='c'){s[j]=s[i];______2______//j++;}s[j]='\0';puts(s);}9、#includestdio.hstructSTUDENT{charname[16];intmath;intenglish;intcomputer;intaverage;};voidGetAverage(structSTUDENT*pst)/*计算平均成绩*/{intsum=0;sum=______1______;//sum+pst-math+pst-English+pst-computerpst-average=sum/3;}voidmain(){inti;structSTUDENTst[4]={{Jessica,98,95,90},{Mike,80,80,90},{Linda,87,76,70},{Peter,90,100,99}};for(i=0;i4;i++){GetAverage(______2______);//&st[i]}printf(Name\tMath\tEnglish\tCompu\tAverage\n);for(i=0;i4;i++){printf(%s\t%d\t%d\t%d\t%d\n,st[i].name,st[i].math,st[i].english,st[i].computer,st[i].average);}}10、#includestdio.h#includemath.hlongf(longn){longm,y=0;m=fabs(n);while(m!=0){y=y*10+m%10;____1____//m=m/10;}if(n=0)returny;else_____2_____//return(-y);}voidmain(){printf(%ld\t,f(12345));printf(%ld\n,f(-34567));}11、#includestdio.hfloatf(float,float*,int);voidmain(){floatb[5]={1.1,2.2,3.3,4.4,5.5};printf(%f\n,f(1.7,b,5));}floatf(_______1________)//floatx,floata[],intn{floaty=a[0],t=1;inti;for(i=1;in;i++){t=t*x;y=y+a[i]*t;}_____2_____//returny}12、#includestdio.h#includestring.h#includectype.hvoidf(char*s){inti=0;while(s[i]!='\0'){if(isdigit(s[i]))____1____(s+i,s+i+1);//strcpy___2___i++;}//else}voidmain(){charstr[80];gets(str);f(str);puts(str);}13、#includestdio.h#includectype.hvoidmain(){chara[80];intn[3]={0},i;gets(a);________1________//for(i=0;a[i]!=’\0’;i++){if(tolower(a[i])='a'&&tolower(a[i])='z')/*统计字母个数*/n[0]++;elseif(________2________)/*统计数字个数*////a[i]='0'&&a[i]='9'n[1]++;elsen[2]++;}for(i=0;i3;i++)printf(%d\n,n[i]);}14、#includestdio.h#includemath.hvoidmain(){inti,a,b,c;for(i=100;i=999;i++){a=i/100;_______1_______//b=i%100/10;c=i%10;if(________2________)//i==a*a*a+b*b*b+c*c*cprintf(%disaArmstrongnumber!\n,i);}}15、#includestdio.hvoidmain(){inta[10],b[10],i;printf(\nInput10numbers:);for(i=0;i10;i++)/*数组输入*/scanf(%d,&a[i]);for(i=1;i10;i++)b[i]=______1______;/*计算b数组中的元素*///a[i]+a[i-1]for(i=1;i10;i++){printf(%3d,b[i]);if(______2______)printf(\n);/*每行打印3个数据*///i%3==0}}
本文标题:C语言程序填空题及答案
链接地址:https://www.777doc.com/doc-6061588 .html