想用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则输出“”继续锻炼“
不过还想再在里面加两段代码
内容是关于皮肤保养时间和摄入卡路里量的。 展开
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则输出“”继续锻炼“
不过还想再在里面加两段代码
内容是关于皮肤保养时间和摄入卡路里量的。 展开
1个回答
展开全部
#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;
}
补充的问题在具体点
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询