#include <stdio.h>
int main()
{
int kilometer, work, leisure ;//定义里程,上班时间,下班时间
float spend; //定义花费
kilometer=12;
work=9;
leisure=18;
if (kilometer<=3)
{
spend=14;
}
else if (kilometer>3)
{
kilometer-=3;
spend=14+kilometer*2.3;
}
if(work<5||leisure>=23)
{
spend=spend*1.2;
}
printf("小明每天花费%d元打车",spend);
return 0;
}
已解决了,输出格式符错了,应该是%f,谢谢大家