C语言程序设计第四五六章习题和课堂测试答案,还有期末C语言复习例题
//3--1矩形面积 #includevoid main(){float a,b;float c,area;printf("n\Please Input a,b:");scanf("%f%f",&a,&b);c=(a+b)*2;area=a*b;printf("c=%f,area=%f\n",c,area);}//3--2输入三位数,输出它各个数位上的数字#includevoid main(){int m,a,b,c;printf("\nPlease Input 三位整数:");scanf("%d",&m);a=m/100;b=m/10%10;c=m%10;printf("a=%d,b=%d,c=%d\n",a,b,c);}//3--3大写字母转换#includevoid main(){char ch;printf("\nPlease Input 大写字母:");scanf("%c",&ch);ch=(ch>='A'&&ch<='Z')?ch=ch+32:ch;printf("ch=%c\n",ch);}//3--3大写字母转换方法二#includevoid main(){char ch;printf("\nPlease Input 大写字母:");scanf("%c",&ch);if (ch>='A'&&ch<='Z')ch=ch+32;printf("ch=%c\n",ch);}//4--1已知圆半径和高,求周长,面积,表面积,体积和圆柱体积#define PI 3.14#include#includevoid main(){double r,h,c,area,s,v,u;printf("\n请输入圆的半径和高:");scanf("%lf%lf",&r,&h);c=2*PI*r;area=PI*pow(r,2);s=4*PI*pow(r,2);v=4.0/3*PI*pow(r,3);u=PI*pow(r,2)*h;printf("c=%lf,area=%lf,s=%lf,v=%lf,u=%lf\n",c,area,s,v,u);}//4--2输入华氏温度求摄氏温度#includevoid main(){float F,C;printf("\n请输入F:");scanf("%f",&F);C=(F-32)*5/9;printf("C=%f\n",C);}//4--3输入五位整数,将它反向输出#includevoid main(){int m,a,b,c,d,e,f;printf("请输入五位整数:");scanf("%d",&m);a=m/10000;b=(m-a*10000)/1000;c=(m-a*10000-b*1000)/100;d=(m-a*10000-b*1000-c*100)/10;e=m-a*10000-b*1000-c*100-d*10;f=e*10000+d*1000+c*100+b*10+a;printf("%d对调后是%d\n",m,f);}//4--4人口#include#includevoid main(){double n,r;r=0.8/100;n=log(2)/log(r+1) ;printf("\n%lf年后我国人口超过26亿",n);}
//4--5求二点间的距离#include#includevoid main(){float x1,y1,x2,y2,l;printf("请输入平面坐标系中二个点的坐标x1 y1 x2 y2:");scanf("%f%f%f%f",&x1,&y1,&x2,&y2);l=pow(pow(x1-x2,2)+pow(y1-y2,2),0.5);printf("二点之间的距离为l=%f\n",l);}//求两点间的距离方法2#include#includevoid main(){float x1,y1,x2,y2,l;printf("请输入平面坐标系中二个点的坐标x1 y1 x2 y2:");scanf("%f%f%f%f",&x1,&y1,&x2,&y2);l=sqrt(pow(x1-x2,2)+pow(y1-y2,2));pri