CE蒟蒻求助

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

tech1540 @ 2023-09-08 21:43:26

#include<iostream>
using namespace std;
int main(){
    int s,v;
    scanf("%d%d",&s,&v);
    int minutes=ceil(1.0*s/v)+10;
    int hh=7
    while(minutes>=60){
        hh=hh-1;
        if(hh<0){
            hh+24;
        }
        minutes=minutes-60;
    }
    printf("%02d:%02d\n",hh,60-minutes);
    return 0;
}

by Max6700 @ 2023-09-08 21:46:28

建议你每步模拟


by FurippuWRY @ 2023-09-08 21:46:49

#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,v;
    scanf("%d%d",&s,&v);
    int minutes=ceil(1.0*s/v)+10;
    int hh=7;
    while(minutes>=60){
        hh=hh-1;
        if(hh<0){
            hh+24;
        }
        minutes=minutes-60;
    }
    printf("%02d:%02d\n",hh,60-minutes);
    return 0;
}

by SZX__HAPPY @ 2023-09-08 21:47:44

if(hh<0){
    hh+24;
}

|