// 设圆半径r = 1.5,圆柱高h = 3,求圆周长,圆面积,圆球表面积,圆球体积,圆柱体积
// 要求:用scanf输入数据,取小数点后两位
#include <stdio.h>
int main()
{
float r,h;
float c,s,sq,vq,vz;
float pai = 3.1415926;
printf("请输入圆半径:");
scanf("%f",&r);
printf("请输入圆柱高:");
scanf("%f",&h);
c = 2 * pai * r;
s = pai * r * r;
sq = 4 * pai * r * r;
vq = ( 4 / 3 ) * pai * r * r * r;
vz = s * h;
printf("圆周长是:%4.2f\n",c);
printf("圆面积是:%4.2f\n",s);
printf("圆球表面积是:%4.2f\n",sq);
printf("圆球体积是:%4.2f\n",vq);
printf("圆柱体积是:%4.2f\n",vz);
return 0;
}
<img src="https://img-blog.csdn.net/20150423121631665?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhcWlhbjU1Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />