求助!5个测试点只过了一个!

B2046 骑车与走路

Lindafish @ 2023-11-22 16:41:26

#include <stdio.h>

int main()
{
    int distance;
    scanf("%d",&distance);
    double time1,time2;
    time1=distance/1.2;
    time2=distance/3.0+50.0;
    if (time1>time2){
        printf("Walk");
    }else if (time2>time1){
        printf("Bike");
    }else{
        printf("All");
    }

    return 0;
}

感觉自己写得没问题啊,怎么会有4个WA呢-_-||


by hexuchen @ 2023-11-22 16:49:36

#include <stdio.h>

int main()
{
    double distance; //也要改double
    scanf("%lfd",&distance);
    double time1,time2;
    time1=distance/1.2;
    time2=distance/3.0+50.0;
    if (time1>time2){
        printf("Walk");
    }else if (time2>time1){
        printf("Bike");
    }else{
        printf("All");
    }

    return 0;
}

by Lhy153 @ 2023-11-22 16:50:29

有没有一种可能你time1和time2反了


by hexuchen @ 2023-11-22 16:52:09

@Lindafish

#include <stdio.h>

int main()
{
    double distance; //也要改double
    scanf("%lf",&distance);
    double time1,time2;
    time2=distance/1.2; //time1 time2搞反了
    time1=distance/3.0+50.0;
    if (time1>time2){
        printf("Walk");
    }else if (time2>time1){
        printf("Bike");
    }else{
        printf("All");
    }

    return 0;
}

by Lindafish @ 2023-11-22 18:36:58

@Lhy153 谢谢佬o(╥﹏╥)o,大小搞错了


by Lindafish @ 2023-11-22 18:37:20

@hexuchen 谢谢大佬♪(・ω・)ノ


by Oscar111111 @ 2024-07-31 14:19:09

同情,3个WA

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double t1=27+n/3.0,t2=n/1.2;
    if(t1==t2) cout<<"All";
    else if(t1>t2) cout<<"Bike";
    else cout<<"Walk";
    return 0;
}

by Oscar111111 @ 2024-07-31 14:25:42

4个WA了。。。。。。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n;
    cin>>n;
    double t1=50.0+n/3.0,t2=n/1.2;
    if(t1==t2) cout<<"All";
    else if(t1>t2) cout<<"Bike";
    else cout<<"Walk";
    return 0;
}

|