#include <stdio.h>
int main()
{
int t=9;
int s=12;
double cost,costb;
if(t>=5&&t<=23)
{
if(s<=3)
{
double cost=14;
}
else if(s>3)
{
double cost=14+2.3*(s-3);
}
return cost;
}
else
{
if(s<=3)
{
double cost=14;
}
else if(s>3)
{
double cost=14+2.3*0.2*(s-3);
}
return cost;
}
int t2=18;
if(t2>=5&&t2<=23)
{
if(s<=3)
{
double costb=14;
}
else if(s>3)
{
double costb=14+2.3*(s-3);
}
return costb;
}
else
{
if(s<=3)
{
double costb=14;
}
else if(s>3)
{
double cost=14+2.3*0.2*(s-3);
}
return costb;
}
double money=cost+costb;
printf("小明每天打车花费%f\n",money);
return 0;
}
下面这个是正确的,改好啦。
#include <stdio.h>
int main()
{
int t=9;
int s=12;
double cost,costb;
if(t>=5&&t<=23)
{
if(s<=3)
{
cost=14;
}
else if(s>3)
{
cost=14+2.3*(s-3);
}
}
else
{
if(s<=3)
{
cost=14;
}
else if(s>3)
{
cost=14+2.3*0.2*(s-3);
}
}
int t2=18;
if(t2>=5&&t2<=23)
{
if(s<=3)
{
costb=14;
}
else if(s>3)
{
costb=14+2.3*(s-3);
}
}
else
{
if(s<=3)
{
costb=14;
}
else if(s>3)
{
cost=14+2.3*0.2*(s-3);
}
}
double money=cost+costb;
printf("小明每天打车花费%.2f\n",money);
return 0;
}
判断时间应该用或吧