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

来源:5-14 综合练习

weixin_慕神3324304

2020-02-19 16:44

#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回答

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

    }

    改好了,拿走不谢。

C语言入门

C语言入门视频教程,带你进入编程世界的必修课-C语言

926210 学习 · 20797 问题

查看课程

相似问题