求助

B2046 骑车与走路

mangochen @ 2022-08-20 19:45:54

40分求助


by ajahjahah @ 2022-08-20 19:48:45

你的代码呢?

我们怎么知道你错哪了


by XCH_0803 @ 2022-08-20 19:57:51

#include<iostream>
using namespace std;
int main(){
    double xingzou,qixing;
    int juli;
    cin>>juli;
    xingzou=juli*1.2;
    qixing=juli*3.0+27+23;
    if(qixing>xingzou)
    cout<<"Walk";
    if(xingzou>qixing)
    cout<<"Bike";
    if(xingzou==qixing)
    cout<<"All";
    return 0;
}

by XCH_0803 @ 2022-08-20 19:58:09

他的代码


by ajahjahah @ 2022-08-20 20:00:15

juli*1.2;

这物理怎么学的?

不应该 t=\frac{d}{s} 吗?


by yeqiwei @ 2022-08-24 20:27:04

这么做:

#include<iostream>
using namespace std;
int main()
{
    int s;
    double tb,tw;
    cin>>s;
    tb=(27.0+23.0)+(s/3.0);
    tw=s/1.2;
    if(tb<tw)
    {
        cout<<"Bike";
    }
    else
    {
        if(tb==tw)
        {
            cout<<"All";
        }
        else
        {
            cout<<"Walk";    
        }
    }
    return 0;
}

求关注!


|