Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct time
- {
- int hour;
- int minutes;
- int seconds;
- };
- int main()
- {
- int time_in_sec,hour,min,sec;
- struct time curr_time;
- do
- {
- printf("Give Hours - Minutes - Seconds : ");
- scanf("%d %d %d", &curr_time.hour, &curr_time.minutes, &curr_time.seconds);
- }
- while((curr_time.hour<0 || curr_time.hour>=12) || (curr_time.minutes<0 || curr_time.minutes>60) || (curr_time.seconds<0 || curr_time.seconds>60)); //elegxos timwn wste h wra pou dinei o xrhsths na einai swsth
- time_in_sec=curr_time.hour*3600+curr_time.minutes*60+curr_time.seconds; // metatropi ths wra se second gia pio eukolh xrhsh
- if(time_in_sec - 59 < 0)
- {
- int i = 0;
- int count = 0;
- while(i <= 59 && time_in_sec != 0)
- {
- time_in_sec = time_in_sec - 1;
- count = count + 1;
- i = i + 1;
- }
- time_in_sec = 11 * 3600 + 59 * 60 + 60;
- time_in_sec = time_in_sec - (59 - count);
- }
- else
- {
- time_in_sec = time_in_sec - 59;
- }
- hour = time_in_sec / 3600;
- min = time_in_sec % 3600 / 60;
- sec = time_in_sec % 3600 % 60;
- printf("%d : %d : %d", hour , min , sec);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement