自己研究了一下,就会这么写,还有没更简洁的写法呢?
#include <stdio.h>
int main()
{
printf("请输入一个时间值(秒):\n");
int time;
scanf("%d",&time);
int h = time / 3600;
int minute = (time - h * 3600) / 60;
int second = (time - h * 3600 - minute * 60) % 60;
printf("%d秒=%d小时%d分钟%d秒\n",time,h,minute,second);
return 0;
} |
|