资源预览内容
第1页 / 共19页
第2页 / 共19页
第3页 / 共19页
第4页 / 共19页
第5页 / 共19页
第6页 / 共19页
第7页 / 共19页
第8页 / 共19页
第9页 / 共19页
第10页 / 共19页
亲,该文档总共19页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
该文档最终解释权由 Yang 所有,未经允许不得转载题目题目1118:赋值表达式与赋值语句,写出程序运行结果:赋值表达式与赋值语句,写出程序运行结果 阅读下面程序,写出运行结果: void main() float a; int b, c; char d, e; a=3.5; b=a; c=330; d=c;4e=; printf(“%f,%d,%d,%c,%c“, a,b,c,d,e); 运行结果为: 3.500000,3,330,J, 提示赋值语句具有类型转换的功能,但可能会改变数据。 3. 基本运算基本运算 题目题目1119:基本运算,写出程序运行结果:基本运算,写出程序运行结果 阅读下面程序,写出运行结果: void main() int a, b, c; float d=15, e, f; a=35%7; b=15/10; c=b+; e=15/10; f=d/10; printf(“%d,%d,%d,%f,%f,%f“, a,b,c,d,e,f); 运行结果为: 0,2,1,15.000000,1.000000,1.500000 提示除法分整除与普通除法之分。5题目题目1126:字符的输入与输出:字符的输入与输出 编程实现由键盘输入一个字符后,在屏幕上输出该字符。 参考程序:参考程序: #include “stdio.h“ main() char ch; ch = getchar(); putchar(ch); 题目题目1127:计算加法:计算加法该文档最终解释权由 Yang 所有,未经允许不得转载编程实现由键盘输入一个加法式,输出正确的结果。(两个加数均为整数) 第一组自测数据 参考程序:参考程序: #include “stdio.h“ main() int a, b; scanf(“%d%*c%d“, printf(“%d“, a+b); 题目题目1014:求圆面积:求圆面积 参考程序:参考程序: #include “stdio.h“ main() float area,r; scanf(“%f“, area=3.14159*r*r; printf(“%0.2f“,area); 3题目题目1015:计算摄氏温度值:计算摄氏温度值 参考程序:参考程序: #include void main() float f,c; scanf(“%f“, c=5.0/9*(f-32); printf(“%.2f“,c); 4参考程序:参考程序: #include “stdio.h“ #include “math.h“ void main() float a,b; scanf(“%f,%f“, if(fabs(a*a+b*b-1)99999999) place=9; else if(n9999999) place=8; else if(n999999) place=7; else if(n99999) place=6; else if(n9999) place=5; else if(n999) place=4; else if(n99) place=3; else if(n9) place=2; else place=1; printf(“%ldn“,place); 题目题目1018:数的排序:数的排序 3,6,9 参考程序:参考程序: #include main() int a,b,c,t; scanf(“%d,%d,%d“, if(ab) t=a;a=b;b=t; if(ac) t=a;a=c;c=t; if(bc) t=b;b=c;c=t; printf(“%d,%d,%d“,a,b,c); 参考程序:参考程序: #include main() char a,b,c,d,e; scanf(“%c%c%c%c%c“, if(a=A) a=a+32; if(b=A) b=b+32; if(c=A) c=c+32; if(d=A) d=d+32; if(e=A) e=e+32; printf(“%c%c%c%c%c“,a,b,c,d,e); #include “stdio.h“ main() int a,b,c,d,e; scanf(“%d %d %d %d %d“, if(a%27=0) printf(“YESn“);else printf(“NOn“); if(b%27=0) printf(“YESn“);else printf(“NOn“); if(c%27=0) printf(“YESn“);else printf(“NOn“); if(d%27=0) printf(“YESn“);else printf(“NOn“); if(e%27=0) printf(“YESn“);else printf(“NOn“);该文档最终解释权由 Yang 所有,未经允许不得转载 参考程序:参考程序: #include “stdio.h“ main() int n; scanf(“%d“, if(n int main() float a,b,c; char op; scanf(“%f%c%f“, switch(op) case +:c=a+b;break; case -:c=a-b;break; case *:c=a*b;break; case /:c=a/b;break; default:printf(“error“); break; printf(“result=%.2f“,c); 9题目题目1024:计算阶乘:计算阶乘 输入正整数n,计算n!,结果用长整型数表示(注n!=1*2*3*.*n) 参考程序:参考程序: #include main() long i,n=1,a; scanf(“%ld“, for(i=1;i main() long n,sum=0,i,t=1;该文档最终解释权由 Yang 所有,未经允许不得转载scanf(“%ld“, for(i=1;i main() long n,sum; scanf(“%ld“, sum=n*n; printf(“%ld“,sum); 注:评判系统不对程序实现细节进行分析,只对运行结果进行评测。注:评判系统不对程序实现细节进行分析,只对运行结果进行评测。 题目题目1026:累加一行字符中的数字:累加一行字符中的数字 参考程序:参考程序: #include main() char c; int s=0,a; while(c=getchar()!=n) if(c=0 scanf(“%ld,%ld“, while(m!=0) r=n%m; n=m; m=r; printf(“%ldn“,n); 该文档最终解释权由 Yang 所有,未经允许不得转载或或 #include main() long m,n,t,i,s; scanf(“%ld,%ld“, t=mn?n:m; for (i=t-1;i=1;i-) if (m%i=0 break; printf(“%d“,s); 题目题目1030:字符变换:字符变换参考程序:参考程序: #include main() char c; while(c=getchar()!=n) if(c=A float a=2,b=1,s=0; scanf(“%d“, for(i=1;i main() int i,num=0,word=0; char c; for(i=0;(c=getchar()!=n;i+) if(c= )word=0; else if(word=0) word=1; num+; printf(“%d“,num); 题目题目1042:百万富翁:百万富翁 参考程序:参考程序: #include #include main() int n,m,i; scanf (“%d“, for (i=1;i=0) break; printf(“%d“,i-1); 15(1)进一步熟悉掌握用while语句、do-while语句和for 语句实现循环的方法。 题目题目1028:求素数:求素数 。 参考程序:参考程序: # include # include main() int m,k,i; for(m=2;mk) printf(“%dn“,m); 题目题目1035:打印菱形:打印菱形 参考程序:参考程序: #include “stdio.h“ #include “math.h“ main() int n,i,j,k; scanf(“%d“, for(i=1;i # include main() int n,i,j,k,h; scanf(“%d“, for(i=-n+1;i=1;h-) printf(“%d“,h); printf(“n“); 17#include main() int a10; int i; for(i=0;i=0;i-) printf(“%dn“,ai); 题目题目1040:统计不同数字个数:统计不同数字个数 参考程序:参考程序: #include“stdio.h“ main()该文档最终解释权由 Yang 所有,未经允许不得转载 int a20; int i,t,p=0; for(i=0;i main() int a34,b43,i,j; for(i=0;i main() int a10; int i,j,t; for(i=0;iaj+1) t=aj; aj=aj+1; aj+1=t; for(i=0;i=0;i-) an1-1-i=si-0; gets(s); n2=strlen(s); for(i=n2-1;i=0;i-) bn2-1-i=si-0; if(n1n2) max=n1; else max=n2; for(i=0;i0) printf(“%d“,cmax); for(i=max-1;i=0;i-) printf(“%d“,ci); 题目:找矩阵中的鞍点题目:找矩阵中的鞍点 参考程序:参考程序: #include main() int i,j,k,a34,max,maxj,flag; for(i=0;imax) max=aij; maxj=j; flag=1; for(k=0;kakmaxj) flag=0; break; if(flag) printf(“%d“,max);break; 该文档最终解释权由 Yang 所有,未经允许不得转载if(!flag) printf(“NO“); 22题目题目1121:定义存贮字符串的字符数组:定义存贮字符串的字符数组 在下面程序中填充定义字符数组的语句,使程序完整。 #include “string.h“ void main() char s80; /*定义字符数组s*/ strcpy(s, “abcdefghijklmn“); printf(“%s“, s); 参考程序:参考程序: 题目题目1123:字符串的输入与输出:字符串的输入与输出 下面程序实现从键盘读入字符串,然后输出到屏幕,请填充必要的语句。 #include “stdio.h“ void main() char s50; printf(“Whats your name?“); gets(s); /*由键盘读入字符串*/ printf(“Y
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号