为了账号安全,请及时绑定邮箱和手机立即绑定

error: expected declaration or statement at end of input } ^

#include <stdio.h>

double taxifee(int hour,int miles)

{

    double perfee;

    int taxi=13;

    if((hour<5 || hour>=23) && miles<=3)

    {

        perfee=2.3;

        printf("打车费为%d\n",taxi+1);

        return 0;

    }

    else if((hour<5 || hour>=23) && miles>3)

    {

        perfee=1.2*perfee;

        printf("打车费为%f\n",taxi+(miles-3)*perfee+1);

        return 0;

    }

    else if((5<=hour<23) && miles>3)

    {

        perfee=2.3;

        printf("打车费为%f\n",taxi+perfee*(miles-3)+1);

        return 0;

    }

    else

    {

        printf("打车费为14\n");

        return 0;

    }

    return 0;

int main()

{

    taxifee(9,12)+taxifee(18,12);

    return 0;

}


正在回答

1 回答


#include <stdio.h>

double taxifee(double hour, double miles)

{

double perfee=2.3;

int taxi = 13;

double sum;

if ((hour < 5 || hour >= 23) && miles <= 3)

{

perfee = 2.3;

sum = taxi + 1;

printf("打车费为%f\n",sum);

return sum;

}

else if ((hour < 5 || hour >= 23) && miles > 3)

{

perfee = 1.2*perfee;

sum = taxi + (miles - 3)*perfee + 1;

printf("打车费为%f\n", sum);

return sum;

}

else if ((5 <= hour < 23) && miles > 3)

{

perfee = 2.3;

sum = taxi + perfee * (miles - 3) + 1;

printf("打车费为%f\n", sum);

return sum;

}

else

{

printf("打车费为14\n");

return 0;

}

return 0;

}

double main()

{

double a = taxifee(9, 12);

double b = taxifee(18, 12);

double c = a + b;

printf("%f",c);

return 0;

}

改好了,拿走不谢。

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

error: expected declaration or statement at end of input } ^

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信