40分求助

B2046 骑车与走路

d18669991101 @ 2024-11-16 18:01:33

哪错了?

#include <iostream>

using namespace std;

int main()
{
    int a,q,z;
    cin>>a;
    q=(a*3.0+27+23);
    z=a*1.2;
    if (q>z)cout<<"Walk";
    if (q<z)cout<<"Bike";
    if (q==z)cout<<"All";
    return 0;
}

教会的加关注


by lan_xing_xing @ 2024-11-16 18:05:22

@d18669991101

#include <iostream>

using namespace std;

int main()
{
    int a,q,z;
    cin>>a;
    //时间=路程/速度 不是*
    q=(a/3.0+27+23);
    z=a/1.2;
    if (q>z)cout<<"Walk";
    if (q<z)cout<<"Bike";
    if (q==z)cout<<"All";
    return 0;
}

by liuboling @ 2024-12-07 20:24:27

@ d18669991101
AC代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int b=27+23+a/3.0,w=a/1.2;//赋值
    if(b>w)cout<<"Walk";
    else if(b<w)cout<<"Bike";
    else cout<<"All";//判断
    return 0;
}//π

|