70pts求助(我是个蒟蒻)

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

Wangbingxiang @ 2024-09-17 21:02:32

#include<iostream>
using namespace std;
int main(){
    int s,v;
    cin>>s>>v;
    int t=s/v;
    if(t*v!=s) t+=1;
    t+=10;
    int h=t/60;
    int hh=h;
    if(h*60==t) h-=1;
    cout<<0;
    int mm=60-(t-hh*60);
    cout<<7-h<<":";
    if(mm==60) mm=0;
    if(mm>=0 && mm<=9) cout<<0;
    cout<<mm;
    return 0;
}

by kanqiqin @ 2024-09-17 21:07:27

@Wangbingxiang 求关

#include<bits/stdc++.h>
using namespace std;
int main(){
    double s,v,t;
    cin>>s>>v;
    t=ceil(s/v)+10;//时间  s/v+额外花费10分钟
    int h=ceil(t/60);//小时 时间/60
    int m=(int)t%60;//分钟 时间%60
    printf("%02d:%02d"/*格式控制*/,(8-h+24)%24,(0-m+60)%60);
    //但是提前的时间不会超过'一天'。( (8-h+24)%24 )
    return 0;//好习惯不能忘。 
    //全剧终! 
}

by Lwx112412 @ 2024-09-17 21:13:38

#include<bits/stdc++.h>
using namespace std;
int main(){
    float s,v;
    cin>>s>>v;
    int t=470-ceil(s/v);
    if (t < 0) 
    {
        t = 24*60 + t;
    }
    int h=t/60;
    int m=t%60;
    if(h<10)
    {
        if(m>=10)
        {
            cout<<"0"<<h<<":"<<m;
        }
        if(m<10)
        {
            cout<<"0"<<h<<":"<<"0"<<m;
        }
    }
    if(h>=10)
    {
        if(m>=10)
        {
            cout<<h<<":"<<m;
        }
        if(m<10)
        {
            cout<<h<<":"<<"0"<<m;
        }
    }
    return 0;
}

by Lwx112412 @ 2024-09-17 21:17:08

@Wangbingxiang 赏个关QAQ


by Wangbingxiang @ 2024-09-17 21:34:33

@Lwx112412@kanqiqin 感谢,没考虑到会在前一天


by Wangbingxiang @ 2024-09-17 21:35:07

@Lwx112412


by Wangbingxiang @ 2024-09-17 21:35:24

@kanqiqin


by Wangbingxiang @ 2024-09-17 21:36:35

QwQ,已关注


|