Time Schedule

题目描述

Xiao Ming is a 2013-BUCTer.This time he has a Programming Contest for 2013th.So he has a lot of things to do recently.Attending classes,doing homework,programing,playing etc.In order to do things more efficient,he makes a time schedule,which has a start time and a end time,but no  time of duration.Can you calculate it?
 

输入

There is more than one test case.Each test case has 2 strings,which means the start and the end time, like this x:y:z   ,x is the number of days after the he made the plan,y is the hour and z is the minute.The end time is bigger than the start time.
 

输出

For each test case,output the  time of duration like this   Case k: x:y  ,x is hour and y is the minute.
 

样例输入

1:8:00
1:9:30
1:22:20
2:6:40
3:8:00
3:9:00
1:0:00
3:0:05
样例输出

Case 1: 1:30
Case 2: 8:20
Case 3: 1:0
Case 4: 48:5
 1 //此题是一道非常简单的题目,并不用多长的代码,只要利用C的特性,读入就可以了,有的同学可能会用读入字符串的方法,然后分离,这样非常的麻烦,不如直接来,下面是代码
 2 
 3 #include <stdio.h>
 4 int main () {
 5     int day1,hour1,minute1;
 6     int day2,hour2,minute2;
 7     int pos=0;
 8     char ch;
 9     while (scanf ("%d%c%d%c%d",&day1,&ch,&hour1,&ch,&minute1)!=EOF) {
10         scanf ("%d%c%d%c%d",&day2,&ch,&hour2,&ch,&minute2);
11         pos++;
12         day1=day2-day1;
13         hour1=hour2-hour1;
14         minute1=minute2-minute1;
15         if (minute1<0) {minute1+=60;hour1-=1;}
16         if (hour1<0) {hour1+=24;day1-=1;}
17         hour1+=day1*24;
18         printf("Case %d: %d:%d\n",pos,hour1,minute1);
19     }
20 }

 

posted @ 2014-02-20 21:13  闪光阳  阅读(406)  评论(0编辑  收藏  举报