#include <iostream> #include <stdlib.h> using namespace std; typedef struct MY_TIME { int HH; int MM; int SS; }MY_TIME; int main() { int n,i; MY_TIME current_time,back_time; char s1[50],s2[50]; int current_total; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%s %s",s1,s2); sscanf(s1,"%d:%d:%d",¤t_time.HH,¤t_time.MM,¤t_time.SS); sscanf(s2,"%d:%d:%d",&back_time.HH,&back_time.MM,&back_time.SS); back_time.HH = back_time.HH % 12; current_total = (current_time.HH *3600 + current_time.MM*60 + current_time.SS) -(back_time.HH *3600 + back_time.MM*60 + back_time.SS); if(current_total < 0) current_total +=12*3600; //注意是12小时制的时间,刚开始搞成24小时了 current_time.HH = current_total/3600; current_time.MM = (current_total - current_time.HH *3600)/60; current_time.SS = current_total - current_time.HH*3600 - current_time.MM*60; printf("%02d:%02d:%02d\n",current_time.HH,current_time.MM ,current_time.SS); } } return 0; }