#include <stdio.h>
void main()
{
unsigned long time;
int days,hours,mins,secs;
int temp;
printf("请输入已过去的时间秒数:\n");
scanf("%lu",&time);
days = time / (24 * 3600); //已过去的天数
temp = (time % (24 * 3600)); //不满一天剩余的秒数(当天的总秒数)
hours = temp / 3600; //当天的时数
mins = temp / 60 - hours * 60; //当天的分数
secs = temp % 60; //当天的秒数
printf("已经过去了%d天\n",days);
printf("现在时间是%02d:%02d:%02d\n",hours,mins,secs);
}
假设从键盘输入从某日凌晨零点零分零秒到现在已经经历的时间(单位:秒),编译程序计算到现在为止已经过了多少天?现在的时间是多少?
最新推荐文章于 2022-10-09 21:10:57 发布