C++30分求助

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

cclearnC @ 2023-11-08 22:07:18

#include<iostream>
using namespace std;
int main() {
    double s, v, needtime, needhour, needminute;
    cin >> s >> v;
    needtime = s / v;
    if (needtime <= 480) {
        needhour = int(needtime) / 60.0;
        needminute = int(needtime) % 60;
        if ((needtime - needminute) > 0)needminute += 1;
        cout << "0" << int(8 - needhour) << ":" << 50 - needminute << endl;
    }
    else if (needtime <= 1320)
    {
        needtime = needtime - 480;
        needhour = int(needtime) / 60.0;
        needminute = int(needtime) % 60;
        if ((needtime - needminute) > 0)needminute += 1;
        cout << 23 - needhour << ":" << 60 - needminute << endl;
    }
    else if (needtime <= 1440)
    {
        needtime = needtime - 1320;
        needhour = int(needtime) / 60.0;
        needminute = int(needtime) % 60;
        if ((needtime - needminute) > 0)needminute += 1;
        cout << 9 - needhour << ":" << 60 - needminute << endl;
    }

    return 0;

}

|