只为伊人心独醉
2016-03-14 12:25
#include <stdio.h>
float Pay(float time ,float mail)
{float pay;
if(time>=5&&time<23){
if(mail<=3){
pay=14;
}else{
pay=14+(mail-3)*2.3;
}
}else{if(mail<=3){
pay=14;
}else{
pay=14+(mail-3)*2.3*1.2;
}
}
return pay;
printf("%f点打车%f公里付费%f元",time,mail,pay);
}
int main()
{ int sum= Pay(9,12)+Pay(18,12);
printf("小明每天打车的总费用为%d元",sum);
return 0;
}
#include <stdio.h>
float Cost(int tim,int mile)
{float a = 2.3;
int b;
if(tim<5||tim>23)
{if(mile <= 3)
b = 13;
else
b = 13+(mile-3)*2.3;}
else
{if(mile <= 3)
b = 13;
else
b=13+(mile-3)*1.2*a;}
return b;
}
int main()
{float sum = Cost(18,12);
printf("小明打车的费用为%.2f\n",sum+2);
return 0;}
C语言入门
926027 学习 · 20793 问题
相似问题