慕雪9555539
2019-12-11 22:34
#include <stido.h>
float ddd(int shijian,int juli)
{
float money;
if(shijian>=23||shijian<5,juli<=3||juli>0&&juli<=3)
{
money=13+1;
}
else if(shijian>=23||shijian<=5,juli>3)
{
money=(juli-3)*4.3+13+1;
}
else if(shijian<=23||shijian>=5,juli>0&&juli<=3)
{
money=13+1;
}
if else(shijian<=23||shijian>=5,juli>3)
{
money=(juli-3)*2.3+13+1;
}
return money;
}
int main()
{
float eee;
eee=ddd(9,12)+ddd(18.12);
printf("%f\n",eee);
return 0;
}
#include <stdio.h> float zj(float lc, float sj) //zj:总价;lc:路程;sj:时间 { float jg; if(lc<=3){ //判断是否超过起步价 jg = 14; //14=起步价+燃油费 } else if(sj>=23||sj<5){ //判断是否需要额外计费 jg = (lc-3)*2.3*1.2+14; } else jg = (lc-3)*2.3+14; } return jg; } int main() { float shangban = zj(12,9); //上班路费 float xiaban = zj(12,18); //下班路费 float money = shangban+xiaban; //总路费 printf("总价为%f\n",money); return 0; }
上面的写错了,把总费用加了20%,应该是每公里,改下就行了
totalMoney = (distance-initKM)*price*speMoney+(distance-initKM)*price+initMoney+otherMoney;
#include <stdio.h> float didi(float,float); int main(){ /* float am = didi(12,9); float pm = didi(12,6); printf("%.2f\n",am+pm);*/ printf("%.2f\n",didi(4,9)); printf("%.2f\n",didi(4,1)); return 0; } // 参数:距离,乘车时间 float didi(float distance, float time){ // 每公里的价钱 float price = 2.3; //起步金额 float initMoney = 13; //起步公里数 float initKM = 3; // 附加费用 float otherMoney = 1; // 收费标准 // 晚上23:00~早上5:00,每公里收费加20% float speMoney = 0.2; // 总价钱 float totalMoney = 0; // 距离小于起步公里数 if(distance<=initKM){ totalMoney = initMoney+otherMoney; }else{ // 正常费用 totalMoney = (distance-initKM)*price+initMoney+otherMoney; if (time>=23||time<=5){ // 费用加20% totalMoney = totalMoney + totalMoney*speMoney; } } return totalMoney; }
#include <stdio.h>
int data(int a);
double km = 2.3;//单价
double oppen = 13.0;//起步
double add = 1.0;//税
double time1 = 9.0;//上班
double time2 = 18.0;//下班
double money = 0.0;//总价
int data(int a)
{
if ( time1 < 5 || time2 > 23 )//判断时间
{
money = oppen + km * (a-3.0) * 1.2 + add;
return money;
}
else
{
money = oppen + km * (a-3.0) + add;
return money;
}
}
int main()
{
data(12);
printf("everyday need money %f",money);
return 0;
}
C语言入门
926207 学习 · 20797 问题
相似问题