#include
#include
using namespace std;
void calccuboid();
void calccylinder();
void calccone();
int main()
{
int choice = -1;
while (choice)
{
cout <<"1.长方体"<
cout
cout
cin >> choice;
switch (choice)
{
case 1:
calccuboid();
break;
case 2:
calccylinder();
break;
case 3:
calccone();
break;
}
}
cout <<"感谢使用本软件!" <
}
void calccuboid()
{
double len,width,height;
cout
cin >>len>>width>>height;
double v = len*width*height;
cout <<"长方体的体积为:"<
}
void calccylinder()
{
double radius,height;
cout
cin >>radius>>height;
double v = 3.14*pow(radius,2)*height;
cout <<"圆柱体的体积为:"<
}
void calccone()
{
double radius,height;
cout
cin >>radius>>height;
double v = 3.14/3*pow(radius,2)*height;
cout <<"圆锥体的体积为:"<<v<<endl;
}
为什么输入0,就会出现cout的感谢使用本软件!语句而输入4,5之类的只会继续循环 。
关于switch case语句的一个问题?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答
悬赏问题
- ¥15 c程序不知道为什么得不到结果
- ¥40 复杂的限制性的商函数处理
- ¥15 程序不包含适用于入口点的静态Main方法
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置