C语言程序填空题及答案_第1页
C语言程序填空题及答案_第2页
C语言程序填空题及答案_第3页
C语言程序填空题及答案_第4页
C语言程序填空题及答案_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选优质文档-倾情为你奉上 程序填空题1、#include <stdio.h>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 <stdio.h>#include <math.h>#define f(x) x*x-5*x+sin(x)void main() int x; float max; _1_ / max=f(1); for(x=2;x&l

2、t;=10;x+) _2_ / if(f(i)>max) max=f(i); printf("%fn",max);3、#include <stdio.h>void main() char c; c=getchar(); if(_1_) / c>='a' && c<'v' c=c+5; else if (c>='v' && c<='z') _2_ /c=c-21; putchar(c);4、#include <stdio.h>v

3、oid 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 <stdio.h> #include <math.h> void main() int n,s=0; scanf("%d",&n); _ 1 _ /n=(n

4、>0?n:-n) ; 2)n=fabs(n); while(n!=0) _ 2 _ / s=s+n%10; n=n/10; printf("%dn",s); 6、/#include <stdio.h>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(a>b) swa

5、p(&a,&b); if(b>c) swap(&b,&c); if(_2_) / a>b swap(&a,&b); printf("%d,%d,%d",a,b,c);7、#include <stdio.h>_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 <stdio

6、.h>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 <stdio.h>struct STUDENT char name16; int math; int english; int computer; int average;void GetAverage(struct STUDENT *pst) /* 计算平均成绩 */ int sum=0; sum

7、 = _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;i<4;i+) GetAverage(_2_); / &sti printf("Name

8、tMathtEnglishtComputAveragen"); for(i=0;i<4;i+) printf("%st%dt%dt%dt%dn",,sti.math,sti.english, puter,sti.average); 10、#include <stdio.h>#include <math.h>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; el

9、se _2_ / return ( -y);void main() printf("%ldt",f(12345); printf("%ldn",f(-34567);11、#include <stdio.h>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

10、=1;i<n;i+) t=t*x; y=y+ai*t; _2_ / return y 12、#include <stdio.h>#include <string.h>#include <ctype.h>void f(char *s) int i=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 <stdio.h

11、>#include <ctype.h>void main() char a80; int n3=0,i; gets(a); _1_ /for(i=0;ai!=0;i+) if (tolower(ai)>='a' && tolower(ai)<='z') /*统计字母个数*/ n0+; else if (_2_) /*统计数字个数*/ ai>='0' && ai<='9'n1+; else n2+; for(i=0;i<3;i+) printf(&quo

12、t;%dn",ni); 14、#include <stdio.h>#include<math.h>void 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 <stdio.h>void main() int a10,b10,i; printf("nInput 10 numbers: "); for (i=0; i<10;i+) /* 数组输入 */ scanf(&qu

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论