//计算时间差
#include<stdio.h>
int main()
{
printf("请输入两个时间,以 04 30的格式输入: ");
int hour1,hour2,minute1,minute2;
int sumMinute1,sumMinute2,timeSub;
scanf("%d %d",&hour1,&minute1);
scanf("%d %d",&hour2,&minute2);
sumMinute1 = hour1*60 + minute1;
sumMinute2 = hour2*60 + minute2;
timeSub = sumMinute2 - sumMinute1;
printf("时间差是%d小时%d分钟",timeSub/60,timeSub%60);
return 0;
}
网友评论