当前位置:首页 > 题库 > 正文内容

PROGRAMMING:[branch] [time conversion a --]

Luz5个月前 (05-10)题库61
Now input a 24-hour time, please program to convert it to 12 hour time format, and output the converted time. If the original time is in the morning, then the space and am need to be output after the conversion time. If the original time is in the afternoon, the space and PM need to be output after the conversion time. Refer to the example for details.
Note: in the 24-hour system, \ [00:00 ~ 12:00 \] is considered as morning, \ [12:01 ~ 23:59 \] is considered as afternoon.
Prompt: for the format of output time: minutes, please use printf (% 02D% 02D am or PM "),% 02D means the width of 2 digits, and 0 is filled in the front if the number is less than 2 digits.
Scanf ("% d") can still be used to output data with 0 in the front. For example, scanf ("% d% d", & H, & M) can be used to input 09:09.
###Input format:
Enter the time of a 24-hour system in the format of HH: mm. The time guarantee is valid. The real hour is minutes.
###Output format:
Output converted 12 hour system time, output data also need to output carriage return line feed.
###Input sample 1:
Here is a set of inputs. For example:
```in
23:59
```
###Output sample 1:
The corresponding output is given here. For example:
```out
11:59 PM
```
###Input sample 2:
Here is a set of inputs. For example:
```in
09:30
```
###Output sample 2:
The corresponding output is given here. For example:
```out
09:30 AM
```
###Input sample 3:
Here is a set of inputs. For example:
```in
12:30
```
###Output sample 3:
The corresponding output is given here. For example:
```out
12:30 PM
```







answer:If there is no answer, please comment
分享给朋友:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。