小白发问,这个c语言程序要怎么编写?
2个回答
展开全部
这是C++,C风格要分别用printf()和scanf()代替cout和cin
int main(){
int weight;
int height;
cout<<"请输入体重:";
cin>>weight;
cout<<"请输入身高:";
cin>>height;
int bmi=weight/(height*height);
cout<<"BMI指数:"<<bmi<<endl;
cout<<bmi<18?1:(bmi<25?2:(bmi<28?3:4))<<endl;
return 0;
}
int main(){
int weight;
int height;
cout<<"请输入体重:";
cin>>weight;
cout<<"请输入身高:";
cin>>height;
int bmi=weight/(height*height);
cout<<"BMI指数:"<<bmi<<endl;
cout<<bmi<18?1:(bmi<25?2:(bmi<28?3:4))<<endl;
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询