如下:
#include<stdio.h>
int main()
{
int a,b;
printf("请输入第一个时间a:");
scanf("%d",&a);
printf("请输入第二个时间b:");
scanf("%d",&b);
int hour1=a/100;//取小时
int minute1=a%100;//取分钟
int hour2=b/100;
int minute2=b%100;
int total1=hour1*60+minute1;
int total2=hour2*60+minute2;
int c=total2-total1;
printf("时间差为%d",c);
return 0;
}
运行结果: