求助,除了前三个测试点全WAo(╥﹏╥)o

P5707 【深基2.例12】上学迟到

Lindafish @ 2024-01-19 14:11:20

#include <stdio.h>

int main()
{
    int s,v;
    scanf("%d %d",&s,&v);
    int i=1;
    double c=s/v;
    while ( i<=c ){
        i++;
    }
    int minute;
    minute=i+10;
    int time1,time2;
    int hour;
    if (minute>60){
        hour=minute/60;
        minute=minute%60;
        time2=60-minute;
        if (hour<=8){
            time1=8-hour;
            if (time2<10){
                printf("0%d:0%d",time1,time2);
            }else{
                printf("0%d:%d",time1,time2);
            }
        }else{
            time1=32-hour;
            if (time1>=10){
                if (time2<10){
                    printf("%d:0%d",time1,time2);
                }else{
                    printf("%d:%d",time1,time2);
                } 
            }else{
                if (time2<10){
                    printf("0%d:0%d",time1,time2);
                }else{
                    printf("0%d:%d",time1,time2);
                } 
            }
        }
    }else{
        time1=7;
        time2=60-minute;
        if (time2<10){
            printf("0%d:0%d",time1,time2);
        }else{
            printf("0%d:%d",time1,time2);
        }         
    }

    return 0;
}

by forever516 @ 2024-01-19 15:49:51

#include<bits/stdc++.h> 
using namespace std;
int main(){
    double s,v,hour,n,minute,g;
    scanf("%d %d",&s,&v);
    minute=ceil(s/v);//等价于你求i的值 
    minute=minute+10;
    hour=floor(minute/60);
    n=minute-hour*60.0;
    if(n!=0){
        n=60-n;
        hour=8-1-hour;
        if(hour<0)hour=24-abs(hour);
    }
    if(n==0){
        hour=8-hour;
        if(hour<0)hour=24-abs(hour);
    }
    if(hour>=10&&n>=10)cout<<hour<<":"<<n<<endl;
    if(hour>=10&&n<10)cout<<hour<<":"<<"0"<<n<<endl;
    if(hour<10&&n>=10)cout<<"0"<<hour<<":"<<n<<endl;
    if(hour<10&&n<10)cout<<"0"<<hour<<":"<<"0"<<n<<endl;

    return 0;
}

这是我修改过后的代码,已AC

给个关注好吗 @Lindafish


|