我这代码有什么问题?

来源:5-14 综合练习

旗开得胜wds

2016-10-22 21:06

运行不对,求解释

写回答 关注

2回答

  • 越飞越高
    2016-11-21 22:26:16

    #include <stdio.h>

    float money;

    float Least = 13.0;

    float tickets(float distance,float time)

    {

        if(time>=5.0&&time<=23.0)

        {

            if(distance<=3.0)

            {

                return (Least+1);

            }

            else

            {

                money=Least+2.3*(distance-3)+1;

                return money;

            }

        }

        else

        {

             if(distance<=3.0)

            {

                return (Least+1);

            }

            else

            {

                money=Least+1.2*2.3*(distance-3)+1;

                return money;

            }

        }

    }

    int main()

    {

        float tickets1 = tickets(12.0,8.0);

        float tickets2 = tickets(12.0,6.0);

        printf("每天打车总费用为:%.2f\n",tickets1+tickets2);

        return 0;

    }

  • 萌新4181064
    2016-10-23 11:07:19
    #include <stdio.h>
    float money;
    float Least = 13.0;
    float tickets(float distance,float time)
    {
        if(time>=5.0&&time<=23.0)
        {
            if(distance<=3.0)
            {
                return (Least+1);
            }
            else
            {
                money=Least+2.3*(distance-3)+1;
                return money;
            }
        }
        else
        {
             if(distance<=3.0)
            {
                return (Least+1);
            }
            else
            {
                money=Least+1.2*2.3*(distance-3)+1;
                return money;
            }
        }
    }
    int main()
    {
        float tickets1 = tickets(12.0,8.0);
        float tickets2 = tickets(12.0,6.0);
        printf("每天打车总费用%f为:",tickets1+tickets2);
        return 0;
    }

     

C语言入门

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

926024 学习 · 20793 问题

查看课程

相似问题