您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > C语言程序设计实验与习题指导课后程序设计答案
P18(1)#includestdio.hintmain(void){intcelsius,fahr;fahr=150;celsius=5*fahr/9-5*32/9;printf(fahr=%d,celsius=%d\n,fahr,celsius);return0;}(2)#includestdio.hintmain(void){intcelsius,fahr;celsius=26;fahr=9*celsius/5+32;printf(celsius=%d,fahr=%d\n,celsius,fahr);return0;}(3)#includestdio.hintmain(void){intaverage,math,eng,comp;math=87;eng=72;comp=93;average=(math+eng+comp)/3;printf(math=%d,eng=%d,comp=%d,average=%d\n,math,eng,comp,average);return0;}(4)#includestdio.hintmain(void){intn,a,b,c;n=152;c=n%10;b=(n/10)%10;a=n/100;printf(整数%d的个位数字是%d,十位数字是%d,百位数字是%d\n,n,c,b,a);return0;}P27(1)#includestdio.h#includemath.hintmain(void){intcelsius,fahr;printf(Entercelsius:);scanf(%d,&celsius);fahr=9*celsius/5+32;printf(fahr%d\n,fahr);return0;}(2)#includestdio.h#includemath.hintmain(void){intmoney,year;doublerate,interest;printf(Entermoney,year,rate:);scanf(%d%d%lf,&money,&year,&rate);interest=money*pow(1+rate,year)-money;printf(interest=%.2f\n,interest);return0;}(3)#includestdio.h#includemath.hintmain(void){doublex,y;printf(Enterx:);scanf(%lf,&x);if(x0){y=pow(x+1,2)+2*x+1/x;}else{y=sqrt(x);}printf(y=f(%f)=%.2f\n,x,y);return0;}(4)#includestdio.hintmain(void){intx,y;printf(Enternum1:);scanf(%d,&x);printf(Enternum2:);scanf(%d,&y);printf(%d+%d=%d\n,x,y,x+y);printf(%d-%d=%d\n,x,y,x-y);printf(%d*%d=%d\n,x,y,x*y);printf(%d/%d=%d\n,x,y,x/y);printf(%d%%%d=%d\n,x,y,x%y);return0;}10的阶乘#includestdio.hintmain(void){inti,n,product;printf(Entern:);scanf(%d,&n);product=1;for(i=1;i=n;i++){product=product*i;}printf(product=%d\n,product);return0;}
本文标题:C语言程序设计实验与习题指导课后程序设计答案
链接地址:https://www.777doc.com/doc-4010581 .html