想用c语言设计一个简单小程序,求代码。

#include<stdio.h>intmain(){floathour;printf("Howmanyhoursdidyouexcise?\nPleaseinputit... #include<stdio.h>
int main()
{float hour;
printf("How many hours did you excise?\nPlease input it ^_^ :");
scanf("%f\n",&hour);
_bool a,b;
a=hour>=0.5;
b=hour<=1;
if(a==true&&b==true)printf("Congratulations!You've had a perfect day!\n");
else if(a==true&&b==false)printf("You are too tired!please have a rest!\n");
else if(a!=true&&b==true)printf("You did not finish your excise,please keep doing it!\n");
return 0;
}
想弄一个小程序,输入当天锻炼的时间后,如果大于0.5小于1,则输出“今天锻炼的不错”,如果大于0.5又大于1,则输出“运动过量”,如果小于0.5则输出“”继续锻炼“
不过还想再在里面加两段代码
内容是关于皮肤保养时间和摄入卡路里量的。
展开
 我来答
阳顶天鹿鼎记
2013-07-30 · TA获得超过502个赞
知道小有建树答主
回答量:675
采纳率:100%
帮助的人:394万
展开全部
#include<stdio.h>
int main()
{
float hour;
printf("How many hours did you excise?\nPlease input it ^_^ :");
scanf("%f",&hour); //输入函数中“”内不能加\n;
bool a,b;
a=hour>=0.5;
b=hour<=1;
if(a&&b)//判断时候,因为a和b本身就是Bool型,直接用自身就行
printf("Congratulations!You've had a perfect day!\n");
else if(a&&!b)
printf("You are too tired!please have a rest!\n");
else if(!a)
printf("You did not finish your excise,please keep doing it!\n");
return 0;
}

补充的问题在具体点
追问
如果想多加一个变量c的话,能否继续用bool呢?
追答
当然可以用bool
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式