我这代码有什么问题?
运行不对,求解释
#include <stdio.h>
float money;
float Least = 13.0;
float tickets(float distance,float time)
{
if(time>=5.0&&time<=23.0)
{
if(distance<=3.0)
{
return (Least+1);
}
else
{
money=Least+2.3*(distance-3)+1;
return money;
}
}
else
{
if(distance<=3.0)
{
return (Least+1);
}
else
{
money=Least+1.2*2.3*(distance-3)+1;
return money;
}
}
}
int main()
{
float tickets1 = tickets(12.0,8.0);
float tickets2 = tickets(12.0,6.0);
printf("每天打车总费用为:%.2f\n",tickets1+tickets2);
return 0;
}
#include <stdio.h> float money; float Least = 13.0; float tickets(float distance,float time) { if(time>=5.0&&time<=23.0) { if(distance<=3.0) { return (Least+1); } else { money=Least+2.3*(distance-3)+1; return money; } } else { if(distance<=3.0) { return (Least+1); } else { money=Least+1.2*2.3*(distance-3)+1; return money; } } } int main() { float tickets1 = tickets(12.0,8.0); float tickets2 = tickets(12.0,6.0); printf("每天打车总费用%f为:",tickets1+tickets2); return 0; }
举报