C语言程序填空题及答案

上传人:M****1 文档编号:498846711 上传时间:2023-03-11 格式:DOC 页数:8 大小:291KB
返回 下载 相关 举报
C语言程序填空题及答案_第1页
第1页 / 共8页
C语言程序填空题及答案_第2页
第2页 / 共8页
C语言程序填空题及答案_第3页
第3页 / 共8页
C语言程序填空题及答案_第4页
第4页 / 共8页
C语言程序填空题及答案_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《C语言程序填空题及答案》由会员分享,可在线阅读,更多相关《C语言程序填空题及答案(8页珍藏版)》请在金锄头文库上搜索。

1、 程序填空题1、#include void main() int n,k=0; scanf(%d,&n);while( _1_ ) / 1)n 2) n!=0; k+; _2_; n=n/10 printf(%dn,k);2、#include #include #define f(x) x*x-5*x+sin(x)void main() int x; float max; _1_ / max=f(1); for(x=2;xmax) max=f(i); printf(%fn,max);3、#include void main() char c; c=getchar(); if(_1_) / c=

2、a & c=v & c=z) _2_ /c=c-21; putchar(c);4、#include void Dec2Bin(int m) int bin32,j; for(j=0;m!=0;j+) binj= _1_; / m%2 m=m/2; for(;j!=0;j-) printf(%d, _2_ ); / binj-1void main() int n; scanf(%d,&n); Dec2Bin(n);5、#include #include void main() int n,s=0; scanf(%d,&n); _ 1 _ /n=(n0?n:-n) ; 2)n=fabs(n); w

3、hile(n!=0) _ 2 _ / s=s+n%10; n=n/10; printf(%dn,s); 6、/#include void swap(_1_) /int *pa , int *pb /*交换两个数的位置*/ int temp; temp = *pa; *pa = *pb; *pb = temp;void main() int a,b,c,temp; scanf(%d%d%d,&a,&b,&c); if(ab) swap(&a,&b); if(bc) swap(&b,&c); if(_2_) / ab swap(&a,&b); printf(%d,%d,%d,a,b,c);7、#i

4、nclude _1_ /long f(int n);void main() printf(%ldn,f(30);long f(int n) if( _2_ ) / n=1|n=2 return 1; else return f(n-1)+f(n-2);8、#include void main() char s80; int i,j; gets(s); for(i=j=0;_1_;i+) / si!=0 if(si != c) sj=si; _2_ /j+; sj=0; puts(s);9、#include struct STUDENT char name16; int math; int en

5、glish; int computer; int average;void GetAverage(struct STUDENT *pst) /* 计算平均成绩 */ int sum=0; sum = _1_; /sum+ pst-math+ pst-English+ pst-computer pst-average = sum/3;void main() int i; struct STUDENT st4=Jessica,98,95,90,Mike,80,80,90, Linda,87,76,70,Peter,90,100,99; for(i=0;i4;i+) GetAverage(_2_);

6、 / &sti printf(NametMathtEnglishtComputAveragen); for(i=0;i4;i+) printf(%st%dt%dt%dt%dn,sti.name,sti.math,sti.english, puter,sti.average); 10、#include #include long f(long n) long m,y=0; m=fabs(n); while(m!=0) y=y*10+m%10; _1_ / m=m/10; if(n=0) return y; else _2_ / return ( -y);void main() printf(%l

7、dt,f(12345); printf(%ldn,f(-34567);11、#include float f(float,float*,int);void main() float b5=1.1,2.2,3.3,4.4,5.5; printf(%fn,f(1.7,b,5);float f( _1_ ) / float x,float a , int n float y=a0,t=1; int i; for(i=1;in;i+) t=t*x; y=y+ai*t; _2_ / return y 12、#include #include #include void f(char *s) int i=

8、0; while(si!=0) if(isdigit(si) _1_(s+i,s+i+1); / strcpy _2_ i+; / elsevoid main() char str80; gets(str); f(str); puts(str);13、#include #include void main() char a80; int n3=0,i; gets(a); _1_ /for(i=0;ai!=0;i+) if (tolower(ai)=a & tolower(ai)=0 & ai=9n1+; else n2+; for(i=0;i3;i+) printf(%dn,ni); 14、#

9、include #includevoid main()int i,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(%d is a Armstrong number!n,i);15、#include void main() int a10,b10,i; printf(nInput 10 numbers: ); for (i=0; i10;i+) /* 数组输入 */ scanf(%d, &ai); for (i=1; i10; i+) bi=_1_; /* 计算b数组中的元素 */ /ai+ai-1 for (i=1; i10; i+) printf(%3d,bi); if (_2_) printf(n); /* 每行打印3个数据 */ /i%3=0

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 国内外标准规范

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号