求大神糾正錯(cuò)誤。謝謝!
#include <stdio.h>
int a(int tim,int mile)
?{ float cost;
? if(tim>=5&&tim<23)
? {
? ? ? if(mile<=3)
? ? ? {
? ? ? ? ? cost=14;
? ? ? }
? ? ? else
? ? ? {
? ? ? ? ? cost=13+2.3*(13-mile)+1;
? ? ? }
? }
? else
? {if(mile<=3)
? ? ? {
? ? ? ? ? cost=14;
? ? ? }
? ? ? else
? ? ? {
? ? ? ? ? cost=13+4.3*(13-mile)+1;
? ? ? }
? }
?}
? return cost;
int main()
{
? ? float x,y;
x=a(6,12);
y=a(18,12);
print("%d",x+y);
?
? ? return 0;
}
2018-07-16
cost為float型所以int a(int tim,int mile)改為float?a(int tim,int mile),return cost"應(yīng)該在花括號里面, print改成printf ,%d改為%f? 剩下的就是表達(dá)式的問題了 你再試試