当前位置:网站首页>7-7 12-24 hour system
7-7 12-24 hour system
2022-07-03 14:09:00 【ᯤ⁹ᴳ⁺ ·】
7-7 12-24 hourly (15 branch )
Write a program , Ask the user to enter 24 Hours of time , Then show 12 Hours of time .
Input format :
The input is given in one line with a middle : Symbol ( Half colon ) Of 24 Hours of time , Such as 12:34 Express 12 spot 34 branch . When the number of hours or minutes is less than 10 when , There are no leading zeros , Such as 5:6 Express 5 Zero 6 branch .
Tips : stay scanf Add... To the format string of :, Give Way scanf To handle this colon .
Output format :
Output the... Corresponding to this time in one line 12 Hours of time , The format of the number part is the same as that entered , Then follow the space , Then follow the string representing the morning AM Or a string representing the afternoon PM. Such as 5:6 PM In the afternoon 5 Zero 6 branch . Be careful , In the habit of English , At noon, 12 O'clock is considered to be afternoon , therefore 24 Hourly 12:00 Namely 12 Hourly 12:0 PM; and 0 The point is considered to be the time of the next day , So it is 0:0 AM.
sample input :
21:11
sample output :
9:11 PMCode :
#include<stdio.h>
int main(){
int h,m;
scanf("%d:%d",&h,&m);
if(h>12){
h=h-12;
printf("%d:%d PM",h,m);
}else if(h==12){
printf("%d:%d PM",h,m);
}else if(h==0){
printf("%d:%d AM",h,m);
}else{
printf("%d:%d AM",h,m);
}
return 0;
}
边栏推荐
- Vite project commissioning
- Qt学习19 Qt 中的标准对话框(上)
- Simulated access
- Qt学习25 布局管理器(四)
- Current situation, analysis and prediction of information and innovation industry
- Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
- Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
- selenium 浏览器(1)
- Go: send the get request and parse the return JSON (go1.16.4)
- Common plug-ins for vite project development
猜你喜欢

Interface for querying IP home

3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)

Multi person collaborative data annotation based on Baidu brain easydata from scratch

How to use lxml to judge whether the website announcement is updated

可编程逻辑器件软件测试

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

MySQL 数据增删改查综合案例

Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)

JVM class loading

Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
随机推荐
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
Configure stylelint
FPGA测试方法以Mentor工具为例
Print. JS -- web page file printing
Golang - command line tool Cobra
MySQL data processing value addition, deletion and modification
项目协作的进度如何推进| 社区征文
TS code automatically generates JS
Qt学习21 Qt 中的标准对话框(下)
【吉林大学】考研初试复试资料分享
Depth and breadth first traversal of tree (regardless of binary tree)
QT learning 17 dialog box and its types
Installation impression notes
Richview trvstyle liststyle list style (bullet number)
Article content typesetting and code highlighting
Spring cup eight school league
Go: send the get request and parse the return JSON (go1.16.4)
Vite project commissioning
QT learning 24 layout manager (III)
怎样删除对象的某个属性或⽅法