Header Ads Widget

Duration

Problem:-

Rahul is a very busy persion he dont wan't to waste his time . He keeps account of duration of each and every work. Now he don't even get time to calculate duration of works, So your job is to count the durations for each work and give it to rahul.

Input:
  • First line will be given by N number of works
  • Next N line will be given SH,SM,EH and EM  each separated by space(SH=starting hr, SM=starting min, EH=ending hr, EM=ending min)
Output:
  • N lines with duration HH MM(hours and minutes separated by space)
SAMPLE INPUT
 
2
1 44 2 14
2 42 8 23
SAMPLE OUTPUT
 
0 30
5 41
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

solution:-

#include<stdio.h>
void main()
{
int n,i,sh,sm,eh,em,h,m;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d%d",&sh,&sm,&eh,&em);
if(em<sm)
{
em=em+60;
eh=eh-1;
}
h=eh-sh;
m=em-sm;
printf("%d %d",h,m);
printf("\n");
}
}

Post a Comment

0 Comments