[UVA] 11650 - Mirror Clock
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;
}