80 没想明白哪里错了

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

oSmile_ @ 2023-09-20 17:46:51


#include <iostream>
#include <cmath>
using namespace std;
float s,v;
int main(){

    cin >> s >> v;
    int time = ceil(s/v);

    int number = 470;
    int losetime;
    losetime = number - time;

    if(losetime > 0){
        cout << "0";
        cout << losetime / 60<<":";
        if(losetime % 60 != 0){
                cout << losetime % 60;
        }else{
            cout <<"00";
        }
        return 0;
    }else if(losetime < 0){
        losetime = 1440 + losetime; 
        if(losetime / 60 < 10 &&losetime /60 >=0){
            cout << "0";
        }
        if(losetime / 60 >= 10){
            cout << losetime / 60 << ":";
            if(losetime % 60 != 0){
                cout << losetime % 60; 
            }else{
                cout << "00";
            }
        }else{
            cout << "8:00";

        }
        return 0;
    }else if(losetime == 0){
        cout << "00:00";
        return 0;
    }
    return 0;
}

by HASPID @ 2023-09-22 22:05:24

#include<iostream>
using namespace std;
int main(){
    int s,v,h=8,m,t;
    cin>>s>>v;
    if(s%v==0)t=s/v;
    else if(s%v!=0)t=s/v+1;
      t+=10;
    if(t%60==0)h=h-t/60;
    else h=h-t/60-1;
    if(h<0)h=24+h;
    if(t%60==0)m=0;
    else m=60-t%60;
    if(h<10&&m<10)cout<<0<<h<<":"<<0<<m;
    else if(h>=10&&m<10)cout<<h<<":"<<0<<m;
    else if(h<10&&m>=10)cout<<0<<h<<":"<<m;
    else if(h>=10&&m>=10)cout<<h<<":"<<m;
}

|