首页 > 试题广场 >

时间转换

[编程题]时间转换
  • 热度指数:66905 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
\hspace{15pt}给定秒数 \textit{seconds},将其转换为对应的小时数、分钟数和秒数,使得总时间不变,但分钟数和秒数都不超过 59

输入描述:
\hspace{15pt}在一行中输入一个整数 \textit{seconds},表示要转换的秒数,满足 \left(0 \leqq \textit{seconds} \leqq10^8\right)


输出描述:
一行,包含三个整数,依次为输入整数对应的小时数、分钟数和秒数(可能为零),中间用一个空格隔开。
示例1

输入

3661

输出

1 1 1

说明

\hspace{15pt}3661 秒转换:3661 \div 3600 =1 小时,余 61 秒;61 \div 60=1 分钟,余 1 秒,结果为 1\,1\,1
x=int(input())
h=x//3600
t1=x%3600
m=t1//60
s=t1%60
print(f"{h} {m} {s}")

发表于 2025-07-19 16:23:40 回复(0)
time = int(input())
hour = time//3600
minute = time%3600//60
second = time%3600%60
print(hour,minute,second)
发表于 2025-07-13 09:34:54 回复(0)
t = int(input())
h = t // 3600
m = t % 3600 // 60
s = t % 3600 % 60
print(h,m,s)
发表于 2025-07-13 04:43:52 回复(0)
seconds=int(input())
a=seconds//3600
b=(seconds-3600*a)//60
c=(seconds-3600*a-60*b)
print(f'{a} {b} {c}')
发表于 2025-07-11 16:54:24 回复(0)
seconds = int(input())
s = seconds // 3600
d = (seconds % 3600) // 60
f = ((seconds % 3600) % 60) % 60
print(s,d,f)
发表于 2025-07-10 09:26:45 回复(0)
x=int(input())
hour = x//3600
min = x//60%60
sec = x%60
print(hour,min,sec)

发表于 2025-06-29 16:50:58 回复(0)
n = int(input())
h = n//3600
m = n//60-h*60
s = n - m*60-h*3600
print(f"{h} {m} {s}")


# a = int(input())
# h, s = divmod(a, 3600)
# m, s = divmod(s, 60)
# print("{} {} {}".format(h, m, s))

发表于 2024-09-28 22:02:33 回复(0)
x= int(input())
hours = x//3600
mins = (x%3600)//60
seconds = (x%3600)%60
print(f"{hours} {mins} {seconds}")
编辑于 2024-04-22 14:46:51 回复(0)
s = int(input())
a = s//3600
b = (s-a*3600)//60
c = s-a*3600-b*60
print(a,b,c)

发表于 2023-06-14 11:19:06 回复(0)
time = int(input())
h = time//(60*60)
m = time//60-60*h
s = time%60
print(h,m,s)
发表于 2022-10-04 22:12:56 回复(0)
seconds = int(input())
hour = seconds//3600
minute = (seconds-hour*3600)//60
second = seconds-hour*3600-minute*60
print("%d %d %d"%(hour,minute,second))
发表于 2022-08-08 20:12:43 回复(0)
a = int(input())
h, s = divmod(a, 3600)
m, s = divmod(s, 60)
print("{} {} {}".format(h, m, s))

发表于 2021-09-09 01:06:38 回复(0)

问题信息

上传者:牛客309119号
难度:
12条回答 4549浏览

热门推荐

通过挑战的用户

查看代码
时间转换