请用程序实现
根据结束时间和用时, 推算开始时间.
注意: 本题采用 24 小时制。即时间范围在0:00:00.00 ~ 23:59:59.99
之间。
函数定义
void time_sub (int *start_hour, int *start_minute, double *start_second, int end_hour, int end_minute, double end_second, double duration);
参数说明
start_hour
, 整型指针, 表示开始时间的小时start_minute
, 整型指针, 表示开始时间的分钟start_second
, 双精度浮点数指针, 表示开始时间的秒数end_hour
, 整型, 表示结束时间的小时end_minute
, 整型, 表示结束时间的分钟end_second
, 双精度浮点数, 表示结束时间的秒数duration
, 双精度浮点数, 表示用时秒数, 其值在0.00 ~ 86400.00
之间
示例1
参数
end_hour = 8
end_minute = 26
end_second = 0.2
duration = 15.2
输出
start_hour: 8
start_minute: 25
start_second: 45.00
初始代码:
#include <stdio.h>
void time_sub (int *start_hour, int *start_minute, double *start_second, int end_hour, int end_minute, double end_second, double duration) {
// TODO 请在此处编写代码,完成题目要求
}
int main () {
int start_hour, start_minute, end_hour = 8, end_minute = 26;
double start_second, end_second = 0.2, duration = 15.2;
time_sub(&start_hour, &start_minute, &start_second, end_hour, end_minute, end_second, duration);
printf("start_hour: %d\nstart_minute: %d\nstart_second: %.2f\n", start_hour, start_minute, start_second);
return 0;
}