问?

这个代码在vs上运行正确,但在交题目的网站上却错误了

#include <ctime>

#include <iostream>

using namespace std;

#include<string>

class wuyie

{

public:

    //秒

    void set_sec(int sec)

    {

        m_sec = sec;

    }

    int get_sec()

    {

        return m_sec;

    }

    //分

    void set_min(int min)

    {

        m_min = min;

    }

    int get_min()

    {

        return m_min;

    }

    //时

    void set_hour(int hour)

    {

        m_hour = hour;

    }

    int get_hour()

    {

        return m_hour;

    }

private:

    int m_hour;

    int m_min;

    int m_sec;

};

int main() {

    //输入一个正整数n

    int n = 0;

    cin >> n;

    int second = 0;

    int sec = 0;

    wuyie now;

    int min = 0;

    int hour = 0;

    now.set_min(min);

    now.set_hour(hour);

    //输入n个正整数t,表示t秒过后

    for (int i = 0; i < n; i++)

    {

        //输入时间

        cin >> second;

        now.set_sec(second);

        //输出时间

        sec += second;

        for (; sec >= 60; )

        {

            if (now.get_sec() >= 60)

            {

                sec = sec - 60;

                now.set_sec(sec);

                min++;

                now.set_min(min);

            }

            if (now.get_min() >= 60)

            {

                min = min - 60;

                now.set_min(min);

                hour = hour++;

                now.set_hour(hour);

            }

        }

        now.set_sec(sec);

        cout << now.get_hour() << ' ' << now.get_min() << ' ' << now.get_sec() << endl;

    }

    return 0;

}

全部评论
报了什么错?
点赞 回复 分享
发布于 2023-11-10 22:06 湖北

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务