#include<iostream>
#define pi 3.1415926535
using namespace std;
int main(){
int n;
double r,h;
while(1){
cout<<"1-Ball"<<endl<<"2-Cylinder"<<endl<<"3-Cone"<<endl<<"other-Exit"<<endl<<"Please enter your command:"<<endl;
cin>>n;
if(n==1){
cout<<"Please enter the radius:"<<endl;
cin>>r;
printf("%.2lf\n",4*pi*r*r*r/3);
}
else if(n==2){
cout<<"Please enter the radius and the height:"<<endl;
cin>>r>>h;
printf("%.2lf\n",pi*r*r*h);
}
else if(n==3){
cout<<"Please enter the radius and the height:"<<endl;
cin>>r>>h;
printf("%.2lf\n",pi*r*r*h/3);
}
else break;
}
return 0;
}
圆形体体积计算器
于 2021-03-18 22:31:01 首次发布