1500 时间计算(1)
Time Limit : 2000/1000 MS(Java/Others) | Memory Limit : 131072/65536 KB(Java/Others)
Submits : 54 | Solved : 46
Description
任意读入一个时间(由时,分,秒组成),将其加n秒后输出,输出的时间格式为hh:mm:ss。当小时等于24小时则置为0。
Input
先输入一个时间,格式如hh:mm:ss。
再输入一个整数n(n<60)
Output
输出原有时间加了n秒以后的时间,以hh:mm:ss的格式输出
Sample Input
14:23:59 2
Sample Output
14:24:01
Template
#include<stdio.h> @-@ //定义结构体类型 struct T time; int main() { int n; scanf("%d:%d:%d",&time.hh,&time.mm,&time.ss); scanf("%d",&n); time.ss+=n; @-@ //调整时间 if(time.hh<10) printf("0%d:",time.hh); else printf("%d:",time.hh); if(time.mm<10) printf("0%d:",time.mm); else printf("%d:",time.mm); if(time.ss<10) printf("0%d\n",time.ss); else printf("%d",time.ss); printf("\n"); return 0; }
HINT
输出格式为hh:mm:ss 例如01:02:03 或 23:55:03
Source
NBU OJ