码迷,mamicode.com
首页 > 其他好文 > 详细

SDNU 1462.时间转换

时间:2019-02-15 23:51:59      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:algo   mes   sam   code   input   输出   script   style   int   

Description

给定一个以秒为单位的时间t,要求用“< H> :< M> :< S> ”的格式来表示这个时间。< H> 表示时间,< M> 表示分钟,而< S> 表示秒,它们都是整数且没有前导的“0”。例如,若t=0,则应输出是“0:0:0”;若t=3661,则输出“1:1:1”。

Input

输入只有一行,是一个整数t(0< =t< =86399)。 

Output

输出只有一行,是以“< H> :< M> :< S> ”的格式所表示的时间,不包括引号。

Sample Input

样例输入1 0 
样例输入2 5436 

Sample Output

样例输出1 0:0:0 
样例输出2 1:30:36 
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int h, m, s, n, miao;
    scanf("%d", &n);
    if(n == 0)printf("0:0:0\n");
    else
    {
        miao = n/60;
        h = miao/60;
        m = miao%60;
        s = n%60;
        printf("%d:%d:%d\n", h, m, s);
    }
    return 0;
}

 

SDNU 1462.时间转换

标签:algo   mes   sam   code   input   输出   script   style   int   

原文地址:https://www.cnblogs.com/RootVount/p/10386432.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!