Since I participated in the TC competition in July of the previous year, I have never participated in it any more, because its input and output formats are hard to accept, and its page fonts are relatively small, it seems so hard for me... excuse me ~~ Lazy! However, I will try my best to participate in it later, in order to improve my programming skills.
Take the 144 question of SRM 200 Div 2 as an example to record the two input and output formats.
Problem Statement |
|
Computers tend to store dates and times as single numbers which represent the number of seconds or milliseconds since a participant date. Your task in this problem is to write a method whattime, which takes an int,Seconds, Representing the number of seconds since midnight on some day, and returns a string formatted as " SecondsIs 0, you shocould return "0: 0", while if seconds is 3661, you shocould return ". |
Definition |
|
Class: |
Time |
Method: |
Whattime |
Parameters: |
Int |
Returns: |
String |
Method signature: |
String whattime (INT seconds) |
(Be sure your method is public) |
|
Limits |
|
Time limit (s ): |
2.000 |
Memory limit (MB ): |
64 |
|
Constraints |
- |
SecondsWill be between 0 and 24*60*60-1 = 86399, aggressive. |
Examples |
0) |
|
|
|
1) |
|
|
|
2) |
|
|
|
3) |
|
|
|
Java version
Public class time {
Public String whattime (INT seconds ){
Int H = secondds/3600;
Int M = (seconds % 3600)/60;
Int S = seconds % 3600-M * 60;
Return H + ":" + M + ":" + S;
}
}
C ++
# Include <iostream>
Using namespace STD;
Class time {
Public:
String whattime (INT seconds)
{
Int H = secondds/3600;
Int M = (seconds % 3600)/60;
Int S = seconds % 3600-M * 60;
Char Buf [40];
Sprintf (BUF, "% d: % d", H, M, S );
Return string (BUF );
}
};