level 2
豆家寂青赎3a
楼主
#include <stdio.h>
#include <math.h>
void myprintf(){
printf("1-Ball\n2-Cylinder\n3-Cone\nother-Exit\nPlease enter your command:\n");
}
double deal(double a){
a=a*100+0.5;
a=(int)(a);
a=a/100.0;
return a;
}
int main(){
double r,h;
while (5){
int bol=0;
myprintf();
scanf("%d",&bol);
if(bol==1){
printf("Please enter the radius:\n"); scanf("%lf",&r); printf("%.2lf\n",deal((4.0/3.0)*4*atan(1.0)*r*r*r)); }else if(bol==2){
printf("Please enter the radius and the height:\n");
scanf("%lf %lf",&r,&h); printf("%.2lf\n",deal(4*atan(1.0)*r*r*h));
}else if(bol==3){
printf("Please enter the radius and the height:\n");
scanf("%lf %lf",&r,&h); printf("%.2lf\n",deal((1.0/3.0)*4*atan(1.0)*r*r*h)); }else{
break;
}
}
return 0;
}





2025年12月02日 12点12分
1
#include <math.h>
void myprintf(){
printf("1-Ball\n2-Cylinder\n3-Cone\nother-Exit\nPlease enter your command:\n");
}
double deal(double a){
a=a*100+0.5;
a=(int)(a);
a=a/100.0;
return a;
}
int main(){
double r,h;
while (5){
int bol=0;
myprintf();
scanf("%d",&bol);
if(bol==1){
printf("Please enter the radius:\n"); scanf("%lf",&r); printf("%.2lf\n",deal((4.0/3.0)*4*atan(1.0)*r*r*r)); }else if(bol==2){
printf("Please enter the radius and the height:\n");
scanf("%lf %lf",&r,&h); printf("%.2lf\n",deal(4*atan(1.0)*r*r*h));
}else if(bol==3){
printf("Please enter the radius and the height:\n");
scanf("%lf %lf",&r,&h); printf("%.2lf\n",deal((1.0/3.0)*4*atan(1.0)*r*r*h)); }else{
break;
}
}
return 0;
}




