24h購物| | PChome| 登入
2012-05-05 22:18:41| 人氣1,301| 回應0 | 上一篇 | 下一篇

[UVA] 11650 - Mirror Clock

推薦 0 收藏 0 轉貼0 訂閱站台


E

Mirror Clock

Input: Standard Input

Output: Standard Output

 

Little Onuvob has learnt to read wall clock.Very often he loudly announces the time. He has a big clock in his room. There is also a mirror in the opposite side of the clock. Few days ago his mother noticed that sometimes Onuvob is announcing wrong time. She became worried and after some investigation she found, Onuvob has no problem in reading time from the clock, the thing is sometimes he reads from the clock in the mirror. So she told him

“Onuvob, you shouldn’t read time from the clock in the mirror.”

 

“But why ma?” curious Onuvob asked.

 

“Because it gives wrong time” mother replied.

 

Now Onuvob looked at the two clocks and realized his mother was telling the truth. Two clocks were not matching. He thought for some time and shouted, “But ma, we can calculate the real time from the clock in the mirror, can’t we?”

 

Can we? Now you have to answer.

Input

The first line of the input contains an integer T (T < 1000), number of test cases. Each of the following T lines will contain the time Onuvob reads from the clock in the mirror. The time will be in the following format: HH:MM

 

Hours and minutes both are integer and the time is always valid.

Output

For each line of Input you have to produce one line of output which will contain the real time, in the same format, namely:

HH:MM

 

See sample input and output for more clarification.

 

Sample Input                              Output for Sample Input

2

12:00

10:09

12:00

01: 51




#include <stdio.h>

int main() {
    int t, h, w;
    scanf("%d", &t);
    while(t--) {
        scanf("%d:%d", &h, &w);
        h = 11-h + (w == 0);
        if(h <= 0)   h += 12;
        if(w != 0)
            w = 60-w;
        printf("%02d:%02d\n", h, w);
    }
    return 0;
}

台長: Morris
人氣(1,301) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA] 10487 - Closest Sums
此分類上一篇:[UVA][Math] 10991 - Region

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文