救救孩子吧,為什么我的只顯示運(yùn)行成功但是不顯示總費(fèi)用呢
#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èi)%f\n",money);
? ? return 0;
}
2021-10-09
下面這個(gè)是正確的,改好啦。
#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("小明每天打車花費(fèi)%.2f\n",money);
? ? return 0;
}
2021-09-27
判斷時(shí)間應(yīng)該用或吧