『壹』 C语言编程 帮忙编个求体积面积的小程序
#include<stdio.h>
#define PI 3.14
main()
{
float r,h,l,s1,s2,v1,v2;
printf("%s","please input the radius and high");
scanf("%f %f",&r,&h);
l=2*PI*r;
s1=PI*r*r;
s2=4*PI*r*r;
v1=4*PI*r*r*r/3;
v2=PI*r*r*h;
printf("%d%d",r,h);
printf("circumference is:%5.2f\n",l);
printf("area of the circle is:%5.2f\n",s1);
printf("ball size is:%5.2f\n",s2);
printf("ball volume is :%5.2f\n",v1);
printf("cylindrical volume is :%5.2f\n",v2);
getch();
}输入数据的时候一定要用实数类型,用空格分开.