资源描述:
《c语言参考资料》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、P834#includeintmain(){charc1,c2;c1=97;c2=98;printf(“c1=%c,c2=%c”,c1,c2);printf(“c1=%d,c2=%d”,c1,c2);return0;}P83n5#includeintmain(){inta,b;floatx,y;charc1,c2;scanf("a=%db=%d",&a,&b);scanf("%f%e",&x,&y);scanf("%c%c",&c1,&c2);printf("a=%d,b=%d,x=%f,
2、y=%f,c1=%c,c2=%c",a,b,x,y,c1,c2);return0;}P83n7#includeintmain(){doubler,h,l,s,sq,vq,vz;floatm=3.1415926;scanf("%lf%lf",&r,&h);l=2*r*m;s=r*r*m;sq=4*r*r*m;vq=4/3*r*r*r*m;vz=s*h;printf("l=%5.2f",l);printf("s=%5.2f",s);printf("sq=%5.2f",sq);printf("vq=%5.
3、2f",vq);printf("vz=%5.2f",vz);return0;}P112n5#include#includeintmain(){floata,b;printf("请输入一个整数a:");scanf("%f",&a);if(a>=1000
4、
5、a<0){printf("请输入不大于1000的整数");scanf("%f",&a);}elseb=sqrt(a);printf("a=%.0f,b=%.0f",a,b);return0;}P112n6#include6、o.h>#includeintmain(){intx,y;printf("请输入x的值x=");scanf("%d,%d",&x,&y);if(x<1)y=x;elseif(x>=10)y=3*x-11;elsey=2*x-1;printf("y=%d",y);return0;}P112n8#include#includeintmain(){intx;chargrade;printf("请输入你的成绩:");scanf("%d",&grade);x=grade/10;swit
7、ch(x){case0:case1:case2:case3:case4:case5:printf("您的等级为E");break;case6:printf("您的等级为D");break;case7:printf("您的等级为C");break;case8:printf("您的等级为B");break;case9:case10:printf("您的等级为A");break;}return0;}P140n3#include#includeintmain(){intm,n,r,s;printf("输
8、入两数:");scanf("%d%d",&m,&n);s=m*n;while(n!=0){r=m%n;m=n;n=r;}printf("最大公约数:%d",m);printf("最小公倍数:%d",s/m);return0;}P140n6#include#includeintmain(){inta,b,n,sum;sum=0;for(n=1;n<=20;n++){for(a=1,b=1;a<=n;a++)b=b*a;sum=sum+b;}printf("%d",sum);return0;
9、}P140n7#include#includeintmain(){inta,b,c,sumA,sumB;floatsumC,sum;for(a=1,sumA=0;a<=100;a++){sumA=sumA+a;}for(b=1,sumB=0;b<=50;b++){sumB=sumB+b*b;}for(c=1,sumC=0;c<=10;c++){sumC=sumC+1/c;}sum=sumA+sumB+sumC;printf("%.0f",sum);return0;}P168n4#include<
10、stdio.h>#includeintmain(){inta[6]={1,3,6,7,9};inti,j,x,t;printf("输入一个数字:");scanf("%d",&x);for(i=0;i<5;i++)i