Time Conversion beeCrowd 1019 URI 1019 Solution C Python coding programming int round floor int() py c solved problem competitive input output print a
Time Conversion
You have to read an integer value. This value is in seconds. All you have to do is convert it to hour:minute:second format.
The formula is:
- Take input.
- Convert the second to hours.
- Then subtract the number of seconds you converted.
- Now convert the remaining to minutes.
- At last, get the remaining seconds.
- Print as said.
The solution in C:
#include <stdio.h>
int main() {
int seconds,minute,hour;
scanf("%d",&seconds);
hour = seconds/3600;
seconds = seconds-(hour*3600);
minute = seconds/60;
seconds = seconds-(minute*60);
printf("%d:%d:%d\n",hour,minute,seconds);
return 0;
}
The solution in Python:
seconds = int(input())
hour = int(seconds/3600)
seconds = seconds-(hour*3600)
minute = int(seconds/60)
seconds = seconds-(minute*60)
print("%d:%d:%d" % (hour,minute,seconds));
COMMENTS