Problem :
Time Conversion
Adapted by Neilor Tonin, URI  Brazil
 Brazil
Timelimit: 1 Brazil
 Brazil
Read an integer value, which is the duration in seconds of a given event in a factory and tell print it in the format expressed in hours:minutes:seconds.
Input
The input file contains an integer N.
Output
Print the read time in the input file (seconds) converted in hours:minutes:seconds like the following example.
| Sample Input | Sample Output | 
| 556 | 0:9:16 | 
| 1 | 0:0:1 | 
| 140153 | 38:55:53 | 
Solution:
#include <stdio.h>  int main() {      int input , hour , minutes , seconds;    scanf("%d",&input);    hour=(input/3600);    minutes=(input-(hour*3600))/60;    seconds= input-((hour*3600)+(minutes*60));    printf("%d:%d:%d\n",hour,minutes,seconds);      return 0;} 
No comments:
Post a Comment