网问答>>圆形体体积计算器 c语言 为什么循环一次就结束了?
问题
已解决

圆形体体积计算器 c语言 为什么循环一次就结束了?

时间:2021-01-25 12:24:28
这个程序只要不输其他数,都不会退出循环,但是我输入一次完成计算后就退出了#include"stdio.h"#include"math.h"#define PI 3.141592653579int main(){ double r,h;//printf("1-Balln2-Cylindern3-Conenother-ExitnPlease enter your command:n") ;while(1){ char in;printf("1-Balln2-Cylindern3-Conenother-ExitnPlease enter your command:n") ;scanf("%c",&in) ;if(in==1){ printf("Please enter the radius:"); scanf("%lf",&r); printf("%.2lfn",(4.0/3*1.0)*PI*pow(r,3)*1.0); }else if(in==2){ printf("Please enter the radius and the height:n"); scanf("%lf %lf",&r,&h); printf("%.2lfn",h*PI*pow(r,2)*1.0);}else if(in==3){ printf("Please enter the radius and the height:n"); scanf("%lf %lf",&r,&h); printf("%.2lfn",1.0/3*PI*r*r*h*1.0); }elsebreak;}return 0;}
最佳回答
这个程序只要不输其
时间:2021-01-25 12:24:36
本类最有帮助
Copyright © 2008-2013 www.wangwenda.com All rights reserved.冀ICP备12000710号-1
投诉邮箱: