您的位置:首页 > 其它

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

2014-08-01 08:03 190 查看
背景 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐