C语言程序设计(第三版)习题库答案.pdfVIP

  • 68
  • 0
  • 约3.2万字
  • 约 26页
  • 2021-10-01 发布于湖北
  • 举报
C语言程序设计 ( 第三版 ) 习题库 1、设圆半径 r=1.5 ,圆柱高 h=3 ,求圆周长、圆面积、圆球表面积、圆球体积、圆柱体积。 用 scanf 输入数据, 输出计算结果, 输出时要求文字说明, 取小数点后两位数字。 请编程序。 #include stdio.h main(){ float r,h,C1,Sa,Sb,Va,Vb; scanf(__ ”%f”__,r); scanf( ”%d”,__ h_); ; C1=2*3.14*r; Sa=3.14*r*r; Sb=4*Sa; Va=4*3.14*r*r*r/3; Vb=Sa*h; printf(___ ” Cl=%.2fSa=%.2fSb=%.2fVa=%.2fVb=%.2f ”,Cl,Sa,Sb,Va,Vb ); } 2、输入一个华氏温度,要求输出摄氏温度。公式为 c=5(F-32)/9 输出要求有文字说明,取位 2 小数。 #include stdio.h main(){ float F,c; scanf(%f,F); ____c=5*(F-32)/9______; printf(c=%.2f,c); } x x 1 3、有一函数: y 2x 1 1 x 10 写一程序,输入 x 值,输出 y 值。 3x 11 x 10 #include stdio.h main(){ int x,y; printf( 输入 x :); scanf(%d,x); if(x1) { /* x1 */ y=x; printf(x=%3d, y=x=%d\n,x,y); } else if (____ x10_______){ /* 1 ≤x -10 */ _____ y=2*x-1 _______; printf(x=%3d, y=2*x-1=%d\n,x,y); } else{ /* x ≥10 */ y=3*x-11; printf(x=%3d, y=3*x-11=%d\n,x# include stdio.h main() { int x,y; scanf(%d,x); if(x1) { y=x;} else if(x=1 x10) { y=2*x-1;} else { y=3*x-11;} printf(%d,y); }# include stdio.h main() { int x,y; scanf(%d,x); if(x1) { y=x;} else if(x=1 x10) { y=2*x-1;} else { y=3*x-11;} printf(%d\n,y); }# include stdio.h main() { int x,y; scanf(%d,x); if(x1) { y=x;} else if(x=1 x10) { y=2*x-1;} else { y=3*x-11;} printf(%d,y); }scanf(%d,x); if(x1) { y=x;} else if(x=1 x10) { y=2*x-1;} else { y=3*x-11;} # include stdio.

文档评论(0)

1亿VIP精品文档

相关文档