给定秒数 seconds ,把秒转化成小时、分钟和秒。
数据范围:
a = int(input()) h, s = divmod(a, 3600) m, s = divmod(s, 60) print("{} {} {}".format(h, m, s))
#include<stdio.h> int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); printf("%d %d %d",a/3600,(a%3600)/60,a%60); return 0; }
int main() { int seconds = 0; int minute = 0; int hour = 0; scanf("%d", &seconds); minute = seconds / 60; //求总的分钟 minute = minute % 60; //求显示的分钟,不能超过60分 hour = seconds / 3600; //求总的小时 hour = hour % 24; //求显示的小时,不能超过24个小时 seconds = seconds % 60; //求余下的秒数 printf("%d %d %d", hour, minute, seconds); return 0; }