计算机二级程序基础CMicrosoft+Word+文档.doc

上传人:11****ws 文档编号:3229476 上传时间:2019-05-26 格式:DOC 页数:19 大小:91KB
下载 相关 举报
计算机二级程序基础CMicrosoft+Word+文档.doc_第1页
第1页 / 共19页
计算机二级程序基础CMicrosoft+Word+文档.doc_第2页
第2页 / 共19页
计算机二级程序基础CMicrosoft+Word+文档.doc_第3页
第3页 / 共19页
计算机二级程序基础CMicrosoft+Word+文档.doc_第4页
第4页 / 共19页
计算机二级程序基础CMicrosoft+Word+文档.doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、01#include void main()int a,b,c,s;a=8;b=12,c=6;s=a+b*c;printf(“s=%dn“,s);02auto break case char continue default dodouble else enum extern float for goto ifint long register return short signed sizeof staticstruct switch typedef union unsigned void volatile while03#include void main() int x,y,z,w;un

2、signed int k;x=10;y=-20;k=30;z=x+k;w=y+k;printf(“x+k=%d,y+k=%dn“,z,w);04#include void main()char c1,c2;c1=a;c2=b;c1=c1-32;c2=c2-32;printf(“%c,%cn“,c1,c2);05#include void main()int x=1,y=2;int x=2;int x=3;printf(“x=%d,y=%dn“,x,y);printf(“x=%d,y=%dn“,x,y);printf(“x=%d,y=%dn“,x,y);06#include void main(

3、)int i=97;char ch=a; putchar(i);putchar(n);putchar(ch);putchar(n);07#include void main()int ch;ch=getchar();putchar(ch);putchar(n);08#include void main()float r,l,s;scanf(“%f“,l=2*3.14159*r;s=3.14159*r*r;printf(“nl=%8.4f“,l);printf(“ns=%8.4fn“,s);09#include void main() float r;scanf(“%f“,printf(“nl=

4、%8.4f“,2*3.14159*r);printf(“ns=%8.4fn“,3.14159*r*r);10#include void main() char ch1,ch2,ch3;ch1=getchar();ch2=getchar();ch3=getchar();putchar(ch3);putchar(n);putchar(ch2);putchar(n);putchar(ch1);putchar(n);11#include void main() char ch1,ch2,ch3;scanf(“%c%c%c“,printf(“%c,%dn“,ch3,ch3);printf(“%c,%dn

5、“,ch2,ch2);printf(“%c,%dn“,ch1,ch1);12#include void main() int num1,num2,num3;float average;printf(“Please input thren numbers:n“);scanf(“%d,%d,%d“,average=(num1+num2+num3)/3.0;printf(“average=%7.2fn“,average);13#include #include void main() float a,b,c,disc,x1,x2;printf(“Please input a,b,c:n“);scan

6、f(“%f,%f,%f“,disc=b*b-4*a*c;if(disc0)|(disc=0)x1=(-b+sqrt(disc)/(2*a);x2=(-b-sqrt(disc)/(2*a);printf(“nx1=%6.2fnx2=%6.2fn“,x1,x2);elseprintf(“This is wrong!n“);14#include #include void main() char a; printf(“Please input a lowercase letter:n“);a=getchar();a=a-32;printf(“%cn“,a);15#include void main(

7、)int a1=1,a2=0,a3=2;printf(“%dn,%dn,%dn,“,a1,a1+a2+a3,a3-a1);16#include #include void main()double x;scanf(“%lf“,if(x=0)printf(“%10.6lfn“,sqrt(x);elseprintf(“That is wrong!n“);17#include #include void main()double x;scanf(“%lf“,if(x=0)printf(“%10.6fn“,sqrt(x);elseprintf(“Enter data error!n“);18#incl

8、ude void main()float a,b;scanf(“%f,%f“,if(ab) printf(“%fn“,a);else printf(“%fn“,b);19#include #include main()double x,y;scanf(“%lf“,if(xmain()double x,y;scanf(“%lf“,if(xvoid main()double x,y;printf(“please input x:n“);scanf(“%lf“,if(xvoid main()double x,y;printf(“please input x:n“);scanf(“%lf“,if(xv

9、oid main()double x,y;printf(“please input x:n“);scanf(“%lf“,if(xvoid main()int tall;char sex;printf(“input sex and tall:n“);scanf(“%c %d“,if(sex=F)if(tall=150)printf(“An“);else printf(“Bn“);else if(tall=170)printf(“An“);else printf(“Bn“);25#include void main()int i;printf(“Please input i:n“);scanf(“

10、%d“,switch(i)case 1:printf(“An“);case 2:printf(“Bn“);case 3:printf(“Cn“);case 4:printf(“Dn“);default:printf(“En“);26#include void main()int i;printf(“Please input i:n“);scanf(“%d“,switch(i)case 1:printf(“An“);break;case 2:printf(“Bn“);break;case 3:printf(“Cn“);break;case 4:printf(“Dn“);break;default

11、:printf(“En“);27#include void main()int i;printf(“Please input i:n“);scanf(“%d“,switch(i)case 1:case 2:case 3:printf(“ABCn“);break;case 4:printf(“Dn“);break;default:printf(“En“);28#include void main()int i;printf(“Please input i:n“);scanf(“%d“,switch(i)case 1:printf(“An“);case 2:printf(“Bn“);case 3:

12、printf(“Cn“);break;case 4:printf(“Dn“);break;default:printf(“En“);29#include void main()int score;scanf(“%d“,switch(score/10) case 10:case 9:printf(“%d:An“,score);break;case 8:case 7:printf(“%d:Bn“,score);break;case 6:printf(“%d:Cn“,score);break;default:printf(“%d:Dn“,score);30#include #include void

13、 main()int score;scanf(“%d“,switch(score/10) case 10:case 9:printf(“%d:An“,score);break;case 8:case 7:printf(“%d:Bn“,score);break;case 6:printf(“%d:Cn“,score);break;default:printf(“%d:Dn“,score);31#include #include void main()float a,b,c,x1,x2,disc;printf(“input a,b,c:n“);scanf(“%f %f %f“,if(fabs(a1

14、e-6)printf(“The equation is not a quadraticn“);elsedisc=b*b-4*a*c;if(disc0)printf(“The equation has not real rootn“);elseif(fabs(disc)1e-6)printf(“The equation has two equal roots:%8.4fn“,-b/(2*a);elsex1=(-b+sqrt(disc)/(2*a);x2=(-b-sqrt(disc)/(2*a);printf(“The equation has distinct real roots:%8.4f,%8.4fn“,x1,x2);

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

当前位置:首页 > 教育教学资料库 > 精品笔记

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。