哪兒錯(cuò)了?
#include <stdio.h>
double getPrice (int hours,double distances)
{
??? double getPrice=0;
??? double distances=0;
??? int startPrice=13;
??? double perPrice=2.3;
??? if(hours<0 || hours>24)
??? {
??????? printf("請輸入正確時(shí)間\n");
??? }
??? if(hours<5 && hours>=23)
??? {
??????? perPrice*=1.2;
??? }
??? if(distances>3)
??? {
??????? getPrice=startPrice+perPrice*(distances-3);
??? }
??? else if
??? {
??????? getPrice=startPrice;
??? }
??? getPrice+=1;
??? return totalPrice;
}
int main()
{
??? int totalPrice;
??? double getPriceMoring=getPrice(9,12);
??? double getPriceEvening=getPrice(18,12);
??? double totalPrice=getPriceMoring+getPriceEvening;
??? printf("小明每天打車的總費(fèi)用為%f\n",totalPrice);
?? return 0;
}
2020-06-22
#include <stdio.h>
double getPrice (int hours,double distances)
{
? ? double getPrice=0;
? ? double distancess=0;
? ? int startPrice=13;
? ? double perPrice=2.3;
? ? if(hours<0 || hours>24)
? ? {
? ? ? ? printf("請輸入正確時(shí)間\n");
? ? ? ? return 0;
? ? }
? ? if(hours<5 && hours>=23)
? ? {
? ? ? ? perPrice*=1.2;
? ? }
? ? if(distances>3)
? ? {
? ? ? ? getPrice=startPrice+perPrice*(distances-3);
? ? }
? ? else?
? ? {
? ? ? ? getPrice=startPrice;
? ? }
? ? getPrice+=1;
? ? return getPrice;
}
int main()http://idcbgp.cn/code/5642#editor-tabs-c
{
? ? //int totalPrice;
? ? double getPriceMoring=getPrice(9,12);
? ? double getPriceEvening=getPrice(18,12);
? ? double totalPrice=getPriceMoring+getPriceEvening;
? ? printf("小明每天打車的總費(fèi)用為%g\n",totalPrice);
? ?return 0;
}
2020-06-22