要实现:
total_sec是以从午夜计算的秒数表示时间。hr、min和sec都是指向变量的指针,这些变量在函数中将分别存储以小时(0~23)、分钟(0~59)和秒(0~59)为单位的等价时间。
#include<stdio.h>
void split_time(long total_sec, int *hr, int *min, int *sec);
int main()
{
int sum_s = 86399, shi, fen, miao;
split_time(sum_s, &shi, &fen, &miao);
return 0;
}
void split_time(long total_sec, int *hr, int *min, int *sec)
{
*hr = total_sec /3600;
*min = total_sec %3600/60;
*sec = total_sec % 3600 % 60;
}