C++80分求助

B2046 骑车与走路

_fox_ @ 2023-07-21 17:29:45

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,bike=23,walk=0;
    cin>>n;
    bike+=n/3;
    walk+=n/1.2;
    if(bike<walk) cout<<"Bike";
    else if(walk<bike) cout<<"Walk";
    else cout<<"All";
    return 0;
}

by Drind @ 2023-07-21 17:30:53

@weiyuangji没有统计开锁需要的时间,bike应初始化为50


by lucky_baizq @ 2023-07-21 17:57:48

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,bike=50,walk=0;
    cin>>n;
    bike+=n/3;
    walk+=n/1.2;
    if(bike<walk) cout<<"Bike";
    else if(walk<bike) cout<<"Walk";
    else cout<<"All";
    return 0;
}

by _fox_ @ 2023-07-24 09:24:01

感谢


|