C语言求圆锥体积的源代码如下:define pi 3.1415/*定义常量pi*/ include<stdio.h> int main(){ float v,r,h;/*用float可以计算小数类型*/ printf("请分别输入圆锥的底r和高h:");scanf("%f %f",&r,&h);v=1.0/3*pi*r*r*h;/*用1.0/3因为整数算术运算有封闭性*/ printf("圆锥体...
int main(){ double r, h; // 圆锥底面半径和高 double s, v; // 圆锥表面积和体积 printf("请输入圆锥底面半径和高(用空格分开):");scanf("%lf %lf", &r, &h);s = PI * r * (r + sqrt(r * r + h * h)); // 计算圆锥表面积 v = PI * r * r * h / ...
printf("圆锥体积为:%f\n",S);return 0;}
include <stdio.h>#define PI 3.14159void main(){int r=15,h=25;printf("V=%f",r*r*h*PI/3);}
r*r+h*h)); //表面积v=PI*(r*r)*h/3; //体积printf("圆锥体的底面周长= %.2f\n",c);printf("圆锥体的表面积= %.2f\n",s);printf("圆锥体的体积= %.2f\n",v);return 0;}//示例运行结果3 5圆锥体的底面周长= 18.85圆锥体的表面积= 83.23圆锥体的体积= 47.12 ...
void main(){ float r,h;printf("请输入半径r:\n");scanf("%f",&r);if(r<=0){ printf("非法输入");} else { printf("请输入高h:\n");scanf("%f",&h);if(h<=0){ printf("非法输入");} else { float s=pi*r*r;float v=s*h/3;printf("体积v=%f\n",v);} } } ...
void f1(int h,int d){ double v;v=h*3.14*(d/2)*(d/2)/3;printf("v=%lf\n",v);} void f2(int h,int d){ double s;s=3.14*(d/2)*(d/2)+sqrt(h*h+(d/2)*(d/2))*(3.14*d/2);printf("s=%lf\n",s);} int main(){ int h,d;printf("输入高:\n")...
include#includevoidmain(){intr,h,pi;r=2;h=3;pi=3.14;printf("圆周长=%d\n",2*pi*r);printf("圆柱底面积=%d\n",pi*r*r);printf("圆柱体积=%d\n",pi*r*r*h);}
include <stdio.h>#define PI 3.1415926main(){double r,h;printf("请输入圆锥底面半径:");scanf("%lf",&r);printf("请输入圆锥高度:");scanf("%lf",&h);printf("该圆锥体积为:%.2lf\n",1.0/3*PI*r*r*h);}