90分求助

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

Gcysnd @ 2024-05-19 14:15:25

代码如下

#include <bits/stdc++.h>
using namespace std;
int main(){

    int s,v,hh=7,mm=50;
    cin >>s >>v;
    while(s>=0){
        s-=v;
        mm--;
        if(mm<0){
            mm=59;
            hh-=1;
        }
        if(hh<0){
            hh=23;
            mm=59;
        }
    }
    if(hh<10){
        cout <<"0" <<hh;
    }else{
        cout <<hh;
    }
    cout <<":";
    if(mm<10){
        cout <<"0" <<mm;
    }else{
        cout <<mm;
    }
    cout <<endl;

    return 0;
}

请问问题出在哪里,求助,得分90(测试点9未通过)


by Justin_love_coding @ 2024-05-19 14:48:22

while(s>=0)改成while(s>0)即可


|