有沒有大佬能解決一下
#include <stdio.h>
float cost(int distance int over)
double price=2.3;
double night;
if(distance<=3)
{
? ? night= 14;
}
else if(over<=23&&over>=5){
? ? night=(distance-3)*price+14;
? ? printf("白天車費為%f\n",night);
? ??
}
else{
? ? night=(distance-3)*(price*1.2)+14;
? ? ?printf("白天車費為%f\n",night);
}
return night;
int main()
{? ?
? ? double allcost = 69.4;
? ? printf("小明每天打車是",allcost);
? ? return 0;
}
2019-07-22
你這個程序有很多問題,我現(xiàn)在先和你說導致程序不能運行的問題。printf("小明每天打車是",allcost);這里allcost對應的%lf你漏了。float cost(int distance int over)這里你沒有用{}括起來,函數(shù)體漏在外面嗎,而且兩個參數(shù)之間要用逗號隔開。最后你主函數(shù)都沒調(diào)用這個函數(shù)。