#include <stdio.h>
int cost(int k, int t)
{
float m;
m = 13.0;
if(k<3)
{
m = m + 1;
printf("小明每天打车的总费用为%f元\n",m);
}
else
{
if(t>23&&t<5)
{
m = m + (k-3)*2.3*1.2 + 1;
printf("小明每天打车的总费用为%f元\n",m);
}
else
{
m = m + (k-3)*2.3 + 1;
printf("小明每天打车的总费用为%f元\n",m);
}
}
}
int main()
{
float total;
total = cost(12,9) + cost(12,18);
printf("小明每天打车的总费用为%f元\n",total);
return 0;
}
#include <stdio.h>
double cost(int t)
{
double m;
int k=12;
m = 13.0;
if(k<3)
{
m = m + 1;
printf("小明每天打车的总费用为%f元\n",m);
return m;
}
else
{
if(t>23&&t<5)
{
m = m + (k-3)*2.3*1.2 + 1;
printf("小明每天打车的总费用为%f元\n",m);
return m;
}
else
{
m = m + (k-3)*2.3 + 1;
printf("小明每天打车的总费用为%f元\n",m);
return m;
}
}
}
int main()
{
double total;
int k=12;
total = cost(9) + cost(18);
printf("小明每天打车的总费用为%f元\n",total);
return 0;
}
if(t>23&&t<5) 这里应该是if(t>23||t<5) 吧
类型的问题吧
求大神们指教!!!