zzulioj 1015: Calculation time interval

Title description
Read in two time points represented by "hour:minute:second", and calculate the time interval in seconds.

Input
There are two lines of input, each line is a time point represented by "hour:minute:second". The test data guarantees that the second time point is later than the first time point.

Output
Output an integer representing the number of seconds in the time interval.

Sample input Copy
08:00:00
09:00:00

The sample output Copy
3600
prompts that the
input data contains ordinary characters, such as colons, and the corresponding characters should be in the corresponding position in the format string of the scanf function.

#include<stdio.h>
int main()
{
    
    
	int h, m, s;
	int h1,m1,s1,sum;
	scanf("%d:%d:%d",&h,&m,&s);
	scanf("%d:%d:%d",&h1,&m1,&s1);
	sum=(h1*3600+m1*60+s1)-(h*3600+m*60+s);
	printf("%d\n",sum);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_53024529/article/details/112705544