资源描述:
《c语言程序填空题及答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、程序填空题1、#includevoidmain(){intn,k=0;scanf("%d",&n);while(_____1_____)//1)n2)n!=0;{k++;_____2_____;n=n/10}printf("%d",k);}2、#include#include#definef(x)x*x-5*x+sin(x)voidmain(){intx;floatmax;______1______//max=f(1);for(x=2;x<=10;x+
2、+)______2______//if(f(i)>max)max=f(i);printf("%f",max);}3、#includevoidmain(){charc;c=getchar();if(______1______)//c>='a'&&c<'v'c=c+5;elseif(c>='v'&&c<='z')______2______//c=c-21;putchar(c);}4、#includevoidDec2Bin(intm){intbin[32],j;for(j=
3、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、#include#includevoidmain(){intn,s=0;scanf("%d",&n);______1______//n=(n>0?n:-n);2)n=fabs(n);while(
4、n!=0){______2______//s=s+n%10;n=n/10;}printf("%d",s);}6、/#includevoidswap(______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(a>b)swap(&a,&b);if(b>c)swap(&b,&c);if(___
5、___2______)//a>bswap(&a,&b);printf("%d,%d,%d",a,b,c);}7、#include_______1______//longf(intn);voidmain(){printf("%ld",f(30));}longf(intn){if(______2______)//n==1
6、
7、n==2return1;elsereturnf(n-1)+f(n-2);}8、#includevoidmain(){chars[80];inti,j;
8、gets(s);for(i=j=0;______1______;i++)//s[i]!=’ ’if(s[i]!='c'){s[j]=s[i];______2______//j++;}s[j]=' ';puts(s);}9、#includestructSTUDENT{charname[16];intmath;intenglish;intcomputer;intaverage;};voidGetAverage(structSTUDENT*pst)/*计算平均成绩*/{intsum=0;su
9、m=______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;i<4;i++){GetAverage(______2______);//&st[i]}printf("Nam
10、etMathtEnglishtComputAverage");for(i=0;i<4;i++){printf("%st%dt%dt%dt%d",st[i].name,st[i].math,st[i].english,st[i].computer,st[i].average);}}10、#include#includelongf(longn){longm,y