Time difference

Description questions
to see two times a standard format, the hour, minutes, there have seconds, formatted as: hh: mm: ss, Instant: minutes: seconds.
You want to know how much difference between these two times it?
Input
Input consists of two lines:
the first line is the first "hours: minutes: seconds" time format.
The second row is the second "hours: minutes: seconds" time format.
And to ensure that this problem must be greater than the first time a second time!
Output
seconds time difference between the two outputs.
Input Example
01:10:10
00:30:30
example output
2380
data range
entered as valid time, the output range is an integer int

#include <stdio.h>

void main(int argc, char* argv[])
{
	int a,b,c,x;
	int d,e,f,y,z;
	scanf ("%d:%d:%d",&a,&b,&c);
	x=a*3600+b*60+c;
	scanf ("%d:%d:%d",&d,&e,&f);
	y=d*3600+e*60+f;
    if (x>y)
	z=x-y;
	printf ("%d\n",z);
	
}

Guess you like

Origin blog.csdn.net/Lhw_666/article/details/91413546