想用c语言设计一个简单小程序,求代码。
发布网友
发布时间:2022-04-30 02:11
我来回答
共1个回答
热心网友
时间:2022-06-28 19:28
#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