我這是哪錯了啊
#include <stdio.h>
double money(float dis,float ofhour)
{
??? float money;
??? if(dis<=3)
??? {
??????? money=14;
??? }
??? else if(dis>3)
??? {
??????? if(ofhour>=5&&ofhour<23)
??????? {
??????????? money=(dis-3)*2.3+14;
??????? }
??????? else if
??????? {?
??????????? money=(dis-3)*2.3*(1+0.2)+14;
??????? }
??? }
??? return money;
}
int main()
{
??? printf("小明打車費用為%.1f\n",texifee(12,9)+texifee(12,6));
??? return 0;
}
2015-12-03
#include<stdio.h>
double getMoney(int dis,int hours)
{
double totalMoney=0.00;
double per=2.30;
double sta=13.00;
if(hours<0||hours>24)
{
printf("請輸入正確的數字:");
return 0;
}
else if(!(hours>=5&&hours<23))
{
per*=1.2;
}
if(dis<=3)
{
totalMoney=sta;
}
else
{
totalMoney=sta+(dis-3)*per;
}
totalMoney++;
return totalMoney;
}
int main()
{
double totalMoney=0.00;
int mor=9;
int aft=18;
int dis=12;
double per=2.30;
totalMoney=getMoney(dis,mor)+getMoney(dis,aft);
printf("小明的搭車費用為:%.2f\n",totalMoney);
return 0;
}
2015-11-29
#include <stdio.h>
double money(float dis,float ofhour)
{
? ? float money;
? ? if(dis<=3)
? ? {
? ? ? ? money=14;
? ? }
? ? else if(dis>3)
? ? {
? ? ? ? if(ofhour>=5&&ofhour<23)
? ? ? ? {
? ? ? ? ? ? money=(dis-3)*2.3+14;
? ? ? ? }
? ? ? ? else
? ? ? ? { ?
? ? ? ? ? ? money=(dis-3)*2.3*(1+0.2)+14;
? ? ? ? }
? ? }
? ? return money;
}
int main()
{
? ? printf("小明打車費用為%.1f\n",texifee(12,9)+texifee(12,6));
? ? return 0;
}
? 把if ?那段代碼里面的if刪除一個 ? 還有?你輸出里面的texifee ?是沒給出??