运行失败,求大神指点。

来源:5-14 综合练习

慕码人7394965

2019-03-04 03:49

include <stdio.h>

int main()

{

    int d,j,t;

    float pay(int j,int t)

    {

    if(j<0||t>24||t<0)

    {

        printf("%s\n","输入错误");

        return 0;

    }

    else if (j<=3) 

    {

        return 14;

    }

    else if (t>=23||t<5)

    {

        float d=14+j*2.3*(1+0.2);

        return d;

    }

    else

    {

        float d=11+j*2.3;

        return d;

    }

    }

    float d1=pay(j,t);

    {

        int j=12;

        int t=9;

        return d1;

    }

    float d2=pay(j,t);

    {

        int j=12;

        int t=18;

        return d2;

    }

    printf("总费用%f元\n",d1+d2);

    return 0;

}


写回答 关注

3回答

  • weixin_慕的地2495175
    2019-03-08 15:45:14
    已采纳

    #include <stdio.h>

    float pay(int j,int t);

    int main()

    {

        printf("总费用%.2f元\n",pay(12,9)+pay(12,18));

        return 0;

    }

    float pay(int j,int t)

    {

           if(j<0||t>24||t<0)

         {

            printf("%s\n","输入错误");

            return 0;

         }

        else if (j<=3) 

         {

            return 14;

         }


        else if (t>=23||t<5)

         {

            float a=14+j*2.3*(1+0.2);

            return a;

         }

        else

         {

            float b=11+j*2.3;

            return b;

         }

    }


  • weixin_慕的地2495175
    2019-03-08 15:46:10

    照你的模子给改了下,感觉你的格式有点混乱。。

    慕码人739...

    谢谢啦

    2019-03-08 19:16:13

    共 1 条回复 >

  • 上官暮
    2019-03-04 19:45:00

    亲,是这样的,我们这边建议您百度查找,希望回答对您有帮助,可以的话请您一定要给一个五星好评呢!

C语言入门

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

924594 学习 · 20763 问题

查看课程

相似问题