码迷,mamicode.com
首页 > 编程语言 > 详细

武汉科技大学ACM:1009: 华科版C语言程序设计教程(第二版)例题5.4

时间:2014-12-13 13:24:31      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   ar   color   sp   on   数据   

Problem Description

老师给小豪出了一道题目:给你一个以秒为单位的值n(32位以内),让你换算成时:分:秒输出。 小豪现在陷入了困惑中,现在请你来帮他解决这个问题。

Input

 输入每行一个正整数n秒。

Output

 对于每组测试数据,输出一行结果时:分:秒。(24小时制)

Sample Input

5
60

Sample Output

00:00:05
00:01:00

HINT

 

 

 

#include<stdio.h>
int hh,mm,ss;
void convertime(long sec)
{
    hh=sec/3600;
    mm=(sec-hh*3600L)/60;
    ss=sec-hh*3600L-mm*60;
}
int  main()
{
   long secs;
   while(scanf("%ld",&secs)!=EOF)
   {
       if(secs>=86400)
       {
        secs=secs%86400;
       }
        convertime(secs);
        printf("%02d:%02d:%02d\n",hh,mm,ss);
   }
    return 1;
}

 

武汉科技大学ACM:1009: 华科版C语言程序设计教程(第二版)例题5.4

标签:des   style   blog   io   ar   color   sp   on   数据   

原文地址:http://www.cnblogs.com/liuwt365/p/4161191.html

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