题目是小明搭车 路程为13公里 3公里内13块 之后每公里2.3元 还有一个时间如果是在晚上11点到凌晨五点之间 每公里多收20%
#include <stdio.h>
int distance(int n,int t)
{
int price;
if(n<=3)
{
return 13;
}
else if(t>=6&&t<=23)
{
price=distance(n-1)+2.3;
}
else
{
price=distance(n-1)+2.3*1.2;
}
return price;
}
int main()
{
int n=13,t=6,price;
price=distance(13,6);
printf("小明来回要花%d元的打车费\n",price);
return 0;
}
我知道是定义函数那边错了 看着就别扭 但是不知道具体错在哪里 能给我指出来吗(n和t分别指路程和时间)
MadMarical
Aaron_0013
zhuceyong244
相关分类