记录详情

Accepted


  
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 2ms 412.0 KiB
#2 Accepted 1ms 404.0 KiB
#3 Accepted 2ms 396.0 KiB
#4 Accepted 1ms 400.0 KiB
#5 Accepted 2ms 384.0 KiB

代码

#include <iostream>
using namespace std;
class Time
{
    int hour;
    int minute;
    int second;
public:
    void init(int h, int m, int s)
    {
        hour = h;
        minute = m;
        second = s;
    }
    void add(int num)
    {
        second = second + num;
        if (second >= 60)
        {
            minute += second / 60;
            second = second % 60;
        }
            
        if (minute >= 60)
        {
            hour += minute / 60;
            minute = minute % 60;
        }
        if (hour >= 24)
        {
            hour = hour % 24;
        }
    }
    void print()
    {
        cout << hour << " " << minute << " " << second;
    }
};
int main()
{
    int h, m, s;
    cin >> h >> m >> s;
    int num;
    cin >> num;
    Time time;
    time.init(h, m, s);
    time.add(num);
    time.print();

    return 0;
}

信息

递交者
类型
递交
比赛
8/29 比赛
语言
C++
递交时间
2021-08-22 09:16:35
评测时间
2021-08-22 09:16:35
评测机
分数
100
总耗时
10ms
峰值内存
412.0 KiB