weixin_慕神3324304
2020-02-19 16:44
#include <stdio.h>
double taxifee(int hour,int miles)
{
double perfee;
int taxi=13;
if((hour<5 || hour>=23) && miles<=3)
{
perfee=2.3;
printf("打车费为%d\n",taxi+1);
return 0;
}
else if((hour<5 || hour>=23) && miles>3)
{
perfee=1.2*perfee;
printf("打车费为%f\n",taxi+(miles-3)*perfee+1);
return 0;
}
else if((5<=hour<23) && miles>3)
{
perfee=2.3;
printf("打车费为%f\n",taxi+perfee*(miles-3)+1);
return 0;
}
else
{
printf("打车费为14\n");
return 0;
}
return 0;
int main()
{
taxifee(9,12)+taxifee(18,12);
return 0;
}
#include <stdio.h>
double taxifee(double hour, double miles)
{
double perfee=2.3;
int taxi = 13;
double sum;
if ((hour < 5 || hour >= 23) && miles <= 3)
{
perfee = 2.3;
sum = taxi + 1;
printf("打车费为%f\n",sum);
return sum;
}
else if ((hour < 5 || hour >= 23) && miles > 3)
{
perfee = 1.2*perfee;
sum = taxi + (miles - 3)*perfee + 1;
printf("打车费为%f\n", sum);
return sum;
}
else if ((5 <= hour < 23) && miles > 3)
{
perfee = 2.3;
sum = taxi + perfee * (miles - 3) + 1;
printf("打车费为%f\n", sum);
return sum;
}
else
{
printf("打车费为14\n");
return 0;
}
return 0;
}
double main()
{
double a = taxifee(9, 12);
double b = taxifee(18, 12);
double c = a + b;
printf("%f",c);
return 0;
}
改好了,拿走不谢。
C语言入门
926210 学习 · 20797 问题
相似问题