求助!!!30分

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

ab12345qw @ 2024-09-23 16:54:43

#include<iostream>
#include<math.h>
int main()
{
    double s,v;
    int t;
    std::cin>>s>>v;
    t=ceil(s/v+10);
    if (t<=480)
    {
        int r=t/60;
        int h=7-t;
        int m=60-t%60;
        std::cout<<h<<":"<<m;
        return 0;
    }
    else
    {
        int w=(t-480)/60;
        int x=23-w;
        int y=60-(t-480-w*60);
        std::cout<<x<<":"<<y;
        return 0;
    }
}

by huangzhiyuan20120518 @ 2024-09-23 17:09:03

h=7-480?


by huangzhiyuan20120518 @ 2024-09-23 17:10:05

t是60倍数时m=60


by huangzhiyuan20120518 @ 2024-09-23 17:10:56

前位补0


by ab12345qw @ 2024-09-23 22:30:44

@huangzhiyuan20120518 感谢回复,马上改!


by huangzhiyuan20120518 @ 2024-09-24 12:31:02

对了吗?


|