#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("请输入正确时间\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\n",totalPrice);
return 0;
}
#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("请输入正确时间\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()https://www.imooc.com/code/5642#editor-tabs-c
{
//int totalPrice;
double getPriceMoring=getPrice(9,12);
double getPriceEvening=getPrice(18,12);
double totalPrice=getPriceMoring+getPriceEvening;
printf("小明每天打车的总费用为%g\n",totalPrice);
return 0;
}
hello.c: In function 'getPrice': hello.c:5:12: error: 'distances' redeclared as different kind of symbol double distances=0; ^~~~~~~~~ hello.c:2:35: note: previous definition of 'distances' was here double getPrice (int hours,double distances) ^~~~~~~~~ hello.c:21:5: error: expected '(' before '{' token { ^ hello.c:25:12: error: 'totalPrice' undeclared (first use in this function) return totalPrice; ^~~~~~~~~~ hello.c:25:12: note: each undeclared identifier is reported only once for each function it appears in hello.c: In function 'main': hello.c:32:12: error: conflicting types for 'totalPrice' double totalPrice=getPriceMoring+getPriceEvening; ^~~~~~~~~~ hello.c:29:9: note: previous declaration of 'totalPrice' was here int totalPrice; ^~~~~~~~~~