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

我这代码有什么问题?

运行不对,求解释

提问者:旗开得胜wds 2016-10-22 21:06

个回答

  • 越飞越高
    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;
    }