求大佬讲解,这代码测试点过了一半(50),不知道哪有问题)

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

williammu @ 2023-11-20 20:44:33

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,v,t,H2=7,hh=59;
    cin>>s>>v;
    t=ceil(s/v)+10;
    if(t<=60)
    {
        hh-=t;
    }
    else
    {
        H2-=floor(t/60);
        hh-=t%60;
    }
    cout<<"0"<<H2<<":"<<hh;
}

by L2YXY @ 2023-11-20 20:52:58

补零的情况


by Rieman_sum @ 2023-11-20 21:03:24

@williammu 有的时候应该输出00:00

你这样会输出0:0


by williammu @ 2023-11-20 21:05:57

@Guo1 谢谢


by williammu @ 2023-11-20 21:06:24

@L2YXY 谢谢


|