为了账号安全,请及时绑定邮箱和手机立即绑定

我这代码有什么问题?

运行不对,求解释

正在回答

2 回答

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

}

0 回复 有任何疑惑可以回复我~
#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;
}

 

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

我这代码有什么问题?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信