问答详情
源自:5-14 综合练习

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;

}


提问者:weixin_慕神3324304 2020-02-19 16:44

个回答

  • qq_慕村0122740
    2020-02-27 16:57:40


    #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;

    }

    改好了,拿走不谢。