#include<iostream>
#include<windows.h>
using namespace std;
const double PI=3.14159;
double s_changfangxing(double a,double b){
return a*b;
}
double c_changfangxing(double a,double b){
return a+a+b+b;
}
double c_zhengfangxing(double a){
return a*4.0;
}
double c_sanjiaoxing(double a,double b,double c){
return a+b+c;
}
double s_zhengfangxing(double a){
return a*a;
}
double c_yuan(double r){
return r*2.0*PI;
}
double s_yuan(double r){
return r*r*PI;
}
double s_sanjiaoxing(double a,double h){
return a*h/2.0;
}
double v_yuanzhu(double r,double h){
return PI*r*r*h;
}
double s_yuanzhu(double r,double h){
double d;
d=r+r;
return 2*PI*r*r+PI*d*h;
}
double v_yuanzhui(double r,double h){
double a;
a=PI*r*r*h;
return a/3.0;
}
double v_changfangti(double a,double b,double c){
return a*b*c;
}
double v_zhengfangti(double a){
return a*a*a;
}
double sb_changfangti(double a,double b,double c){
return 2.0*(a*b+a*c+b*c);
}
double sb_zhengfangti(double a){
return 6.0*a*a;
}
double sb_yuanzhu(double r,double h){
return 2*s_yuan(r)+c_yuan(r)*h;
}
int main()
{
int a,b,c,d,e;
bool flag=true;
double c_chang_a,c_chang_b,c_zheng_a,c_yuan_r,c_sanjiaoxing_a,c_sanjiaoxing_b,c_sanjiaoxing_c,s_chang_a,s_chang_b,s_zheng_a,s_yuan_r,s_sanjiaoxing_a,s_sanjiaoxing_h,v_changfangti_a,v_changfangti_b,v_changfangti_c,v_zhengfangti_a,v_yuanzhui_r,v_yuanzhui_h,v_yuanzhu_r,v_yuanzhu_h,sb_changfangti_a,sb_changfangti_b,sb_changfangti_c,sb_zhengfangti_a,sb_yuanzhu_r,sb_yuanzhu_h;
cout<<"欢迎来到超级图形计算器!"<<endl;
system("pause");
system("cls");
while(flag){
Sleep(1000);
cout<<"请问你要:1.计算周长;2.计算面积;3.计算体积;4.计算表面积;5.退出 ";
cin>>a;
switch(a){
case 1:
cout<<"请问你要计算哪种图形的周长:";
cout<<"1.长方形;2.正方形;3.圆;4.三角形 ";
cin>>b;
switch(b){
case 1:
cout<<"请输入长方形的长:";
cin>>c_chang_a;
cout<<"请输入长方形的宽:";
cin>>c_chang_b;
cout<<"长方形的周长:"<<c_changfangxing(c_chang_a,c_chang_b)<<endl;
system("pause");
system("cls");
break;
case 2:
cout<<"请输入正方形的边长:";
cin>>c_zheng_a;
cout<<"正方形的周长:"<<c_zhengfangxing(c_zheng_a)<<endl;
system("pause");
system("cls");
break;
case 3:
cout<<"请输入圆的半径:";
cin>>c_yuan_r;
cout<<"圆的周长是:"<<c_yuan(c_yuan_r)<<endl;
system("pause");
system("cls");
break;
case 4:
cout<<"请输入三角形的第一条边:";
cin>>c_sanjiaoxing_a;
cout<<"请输入三角形的第二条边:";
cin>>c_sanjiaoxing_b;
cout<<"请输入三角形的第三条边:";
cin>>c_sanjiaoxing_c;
cout<<"三角形的周长是:"<<c_sanjiaoxing(c_sanjiaoxing_a,c_sanjiaoxing_b,c_sanjiaoxing_c)<<endl;
system("pause");
system("cls");
break;
default:
cout<<"输入错误,请重新输入!"<<endl;
Sleep(2000);
system("pause");
break;
}
break;
case 2:
cout<<"请问你要计算哪种图形的面积:";
cout<<"1.长方形;2.正方形;3.圆;4.三角形 ";
cin>>c;
switch(c){
case 1:
cout<<"请输入长方形的长:";
cin>>s_chang_a;
cout<<"请输入长方形的宽:";
cin>>s_chang_b;
cout<<"长方形的面积:"<<s_changfangxing(s_chang_a,s_chang_b)<<endl;
system("pause");
system("cls");
break;
case 2:
cout<<"请输入正方形的边长:";
cin>>s_zheng_a;
cout<<"正方形的面积:"<<s_zhengfangxing(s_zheng_a)<<endl;
system("pause");
system("cls");
break;
case 3:
cout<<"请输入圆的半径:";
cin>>s_yuan_r;
cout<<"圆的面积是:"<<s_yuan(s_yuan_r)<<endl;
system("pause");
system("cls");
break;
case 4:
cout<<"请输入三角形的底:";
cin>>s_sanjiaoxing_a;
cout<<"请输入三角形的高:" ;
cin>>s_sanjiaoxing_h;
cout<<"三角形的面积是:"<<s_sanjiaoxing(s_sanjiaoxing_a,s_sanjiaoxing_h)<<endl;
system("pause");
system("cls");
break;
default:
cout<<"输入错误,请重新输入!"<<endl;
Sleep(2000);
system("cls");
break;
break;
}
case 3:
cout<<"请问你要计算哪种图形的体积:";
cout<<"1.长方体;2.正方体;3.圆锥;4.圆柱 ";
cin>>d;
switch(d){
case 1:
cout<<"请输入长方体的长:";
cin>>v_changfangti_a;
cout<<"请输入长方体的宽:";
cin>>v_changfangti_b;
cout<<"请输入长方体的高:";
cin>>v_changfangti_c;
cout<<"长方体的体积是:"<<v_changfangti(v_changfangti_a,v_changfangti_b,v_changfangti_c)<<endl;
system("pause");
system("cls");
break;
case 2:
cout<<"请输入正方体的棱长:";
cin>>v_zhengfangti_a;
cout<<"正方体的体积:"<<v_zhengfangti(v_zhengfangti_a)<<endl;
system("pause");
system("cls");
break;
case 3:
cout<<"请输入圆锥的底面半径:";
cin>>v_yuanzhui_r;
cout<<"请输入圆锥的高:";
cin>>v_yuanzhui_h;
cout<<"圆锥的体积:"<<v_yuanzhui(v_yuanzhui_r,v_yuanzhui_h)<<endl;
system("pause");
system("cls");
break;
case 4:
cout<<"请输入圆柱的底面半径:";
cin>>v_yuanzhu_r;
cout<<"请输入圆柱的高:";
cin>>v_yuanzhui_h;
cout<<"圆柱的体积:"<<v_yuanzhu(v_yuanzhu_r,v_yuanzhu_h)<<endl;
system("pause");
system("cls");
break;
default:
cout<<"输入错误,请重新输入!"<<endl;
Sleep(2000);
system("pause");
break;
}
break;
case 4:
cout<<"请问你要计算哪种图形的表面积:";
cout<<"1.长方体;2.正方体;3.圆柱 ";
cin>>e;
switch(e){
case 1:
cout<<"请输入长方体的长:";
cin>>sb_changfangti_a;
cout<<"请输入长方体的宽:";
cin>>sb_changfangti_b;
cout<<"请输入长方体的高:";
cin>>sb_changfangti_c;
cout<<"长方体的表面积是:"<<sb_changfangti(sb_changfangti_a,sb_changfangti_b,sb_changfangti_c);
system("pause");
system("cls");
break;
case 2:
cout<<"请输入正方体的棱长:";
cin>>sb_zhengfangti_a;
cout<<"正方体的表面积:"<<sb_zhengfangti(sb_zhengfangti_a)<<endl;
system("pause");
system("cls");
break;
case 3:
cout<<"请输入圆柱的底面半径:";
cin>>sb_yuanzhu_r;
cout<<"请输入圆柱的高:";
cin>>sb_yuanzhu_h;
cout<<"圆柱的表面积:"<<sb_yuanzhu(sb_yuanzhu_r,sb_yuanzhu_h)<<endl;
system("pause");
system("cls");
break;
default:
cout<<"输入错误,请重新输入!"<<endl;
Sleep(2000);
system("cls");
}
break;
case 5:
flag=false;
break;
default:
cout<<"输入错误,请重新输入!"<<endl;
Sleep(2000);
system("cls");
}
}
return 0;
}
共 3 条回复
建议放上向量之类的计算几何内容
可计算图形太少
👍