现在的位置: 首页 > 综合 > 正文

2013年北邮网研院上机真题(B)

2018年09月23日 ⁄ 综合 ⁄ 共 551字 ⁄ 字号 评论关闭


 统计时间间隔

Accept:130  

  Submit:1132

Time Limit:1000MS  

  Memory Limit:65536KB

Description

给出两个时间(24小时制),求第一个时间至少要经过多久才能到达第二个时间。给出的时间一定满足的形式,其中xy分别代表小时和分钟。$0x24,0y 60

InputFormat

第一行为数据组数T(1≤T≤50000)

每组数据包括两行,分别代表两个时间。

OutputFormat

每组数据输出一行,表示最少经过的分钟数。

SampleInput

2

7:00

7:00

7:00

8:00

SampleOutput

0

60

# include <stdio.h> 
  
 int main() 
 { 
     int t; 
     int i; 
     int x1,y1,x2,y2; 
  
     scanf("%d",&t); 
  
     for(i=0;i<t;i++) 
     { 
         scanf("%d%:%d",&x1,&y1); 
         scanf("%d%:%d",&x2,&y2); 
  
         if(x1==x2) 
             printf("%d\n",y2-y1); 
         else 
             if(y1>y2) 
                 printf("%d\n",60*(x2-x1)+(60-y1)+y2); 
             else 
                 printf("%d\n",60*(x2-x1)+(y2-y1)); 
     } 
  
     return 0; 
 }

抱歉!评论已关闭.