我只得了80分,麻烦大佬指正

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

lanyaohhh @ 2023-10-18 22:08:33

#include<iostream>
using namespace std;
int main()
{
    int h1,h2,h3,h4,p;
    double s,v,o;                   
    cin>>s>>v;
    o=s/v;
    p=int(o);
    if (o>p){o=o+1;}
    else{o=p;}
    h1=o+10;
    if (h1<=480 or h1>1320)
    {
        if (h1<=480)
        {h2=480-h1;}
        else 
        {h2=1920-h1;}
        h3=h2/60;
        h4=h2%60;
        cout<<"0"<<h3<<":"<<h4;
    }
    else
    {
        h2=1920-h1;
        h3=h2/60;
        h4=h2%60;
        cout<<h3<<":"<<h4;
    }
    return 0;
} 

by Puntus @ 2023-10-19 10:43:22

需要判断一下分钟是否小于10,如果分钟小于10,也需要前面加个0的,例如从3点5分除法,应该输出03:05,你这样写应该会输出03:5吧


by lanyaohhh @ 2023-10-21 13:45:36

@Puntus 感谢,已经通过解决了~~~


|