不知道哪里出错了,求解!
#include
float pay(int dis,int time) { float pay; if(time>=23||time<5) { pay=14+(dis-3)*2.3*1.2; } else { pay=14+(dis-3)*2.3; } return pay; } int main() { printf(小明每天打车的总费用"%d\n",pay(12,9),pay(12,18)); return 0; } 为什么不对啊?急求。。。。#include
float pay(int dis,int time) { float pay; if(time>=23||time<5) { pay=14+(dis-3)*2.3*1.2; } else { pay=14+(dis-3)*2.3; } return pay; } int main() { printf(小明每天打车的总费用"%d\n",pay(12,9),pay(12,18)); return 0; } 为什么不对啊?急求。。。。2018-02-20
#include <stdio.h>
float getCost(int hour,float km)
{
float cost;
if(23<=hour||hour<5)
{
if(km<=3)
cost=13.0+1.0;
else
cost=13.0+(km-3)*2.3*1.2+1.0;
}
else
{
if(km<=3)
cost=13.0+1.0;
else
cost=13.0+(km-3)*2.3+1.0;
}
return cost;
}
int main()
{
float money=getCost(9,12.0)+getCost(18,12.0);
printf("小明每天打车的总费用为:%.1f",money);
return 0;
}
#include<stdio.h>
float xiaokai(int w,int r,float t,int y,int u)//定义费用函数
{
float jg;
if(w-y>0)
{
jg=(w-y)*t+u+r;
}
else
{
jg=u+r;
}
return jg;
}
float sj(n)//定义时间函数
{
float i;
switch(n)
{
case 1:
i=1.2;
break;
case 2:
i=1.2;
break;
case 3:
i=1.2;
break;
case 4:
i=1;
break;
case 5:
i=1.2;
break;
case 6:
i=1;
break;
case 7:
i=1;
break;
case 8:
i=1;
break;
case 9:
i=1;
break;
case 10:
i=1;
break;
case 11:
i=1;
break;
case 12:
i=1;
break;
case 13:
i=1;
break;
case 14:
i=1;
break;
case 15:
i=1;
break;
case 16:
i=1;
break;
case 17:
i=1;
break;
case 18:
i=1;
break;
case 19:
i=1;
break;
case 20:
i=1;
break;
case 21:
i=1;
break;
case 22:
i=1;
break;
case 23:
i=1.2;
break;
case 24:
i=1.2;
break;
}
return i;
}
int main()
{
printf("%f",xiaokai(12,1,2.3,3,13)*sj(9)/*←括号类填写上班时间*/+xiaokai(12,1,2.3,3,13)*sj(18)/*←括号内填写下班时间*/);
return 0;
}
//输出结果为 69.40002
#include <stdio.h>
float taxiFee(int time,int miles)
{
float money;
if(miles<=3)
{
money=13+1;
printf("打车费用为%d元\n",money);
}
else
{
if(time>=23 || time<=5)
{
money=13+1+(miles-3)*2.3*1.2;
printf("打车费用为%d元\n",money);
}
else
{
money=14+(miles-3)*2.3;
printf("打车费用为%d元\n",money);
}
}
return money;
}
int main()
{
float sum=taxiFee(9,12)+taxiFee(18,12);
printf("每天打车费用为%f\n",sum);
return 0;
}
举报