tyvj begin 闰秒 wa了2个小时竟然 【水题】

背景 Background
Unit 2, Section D
描述 Description
对于给定的秒数,请输出它以时:分:秒的形式的表
示。
当然,为了增加难度,我们假设每一分钟都有闰秒,
也就是说一分钟有61秒。
输入格式 InputFormat
输入一行,一个整数,表示秒数(0<n<5000)。
输出格式 OutputFormat
输出一行,以时:分:秒的形式的表示。

我的wa点就是它的分是61秒,可是到小时就又变为60进1了。

<span style="font-size:14px;">#include <iostream>

using namespace std;

int main()
{
    int s,h,m;
    cin>>s;
    if(s<61)
    {
            if(s<10&&s>0)cout << "00:00:0" <<s<< endl;
            else if(s>=10)cout<<"00:00:"<<s<<endl;
    }
    else if(s<3660)//(s<3721)
    {
        m=s/61;//m=s/61;
        s=s%61;
        if(m<10&&m>0) cout<<"00:0"<<m;
        else cout<<"00:"<<m;
        if(s<10) cout<<":0"<<s<<endl;
        else cout<<":"<<s<<endl;
    }
    else if(s<5000)
        {
            h=s/3660;//s/3721;
            s=s%3660;//s%3721;
            m=s/61;
            s=s%61;
            if(h<10)cout<<"0"<<h;
            else cout<<h;
            if(m<10)
                cout<<":0"<<m;
            else cout<<":"<<m;
            if(s<10) cout<<":0"<<s<<endl;
            else cout<<":"<<s<<endl;

        }
    return 0;
}</span>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值