You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
485 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <stdio.h>
//学习资料https://jingyan.baidu.com/article/c33e3f48e0e01eea15cbb593.html
int main(void) {
int hour1,hour2;
int minute1,minute2;
printf("请输入2组时间输完一组按下enter按照——小时——分钟格式\n");
scanf("%d %d",&hour2,&minute2);
scanf("%d %d",&hour1,&minute1);
int ih = hour2-hour1;
int im = minute2-minute1;
if(ih<0) {
ih = -ih;
im = -im;
}
if (im<0) {
im = im+60;
ih--;
}
printf("两个时间的时间差为%d小时%d分钟",ih,im);
return 0;
}