当前位置:网站首页>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 PM
Code :
#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;
}
边栏推荐
- Analysis of the characteristics of page owner
- 关于回溯问题中的排列问题的思考(LeetCode46题与47题)
- 全局事件总线
- Simulated access
- Installation impression notes
- Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
- Qt学习22 布局管理器(一)
- 战略、战术(和 OKR)
- How to delete an attribute or method of an object
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
猜你喜欢
Interface for querying IP home
28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
Qt学习20 Qt 中的标准对话框(中)
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
GoLand 2021.2 configure go (go1.17.6)
GoLand 2021.1.1: configure the multi line display of the tab of the open file
Programmable logic device software testing
Implementation of Muduo asynchronous logging
MySQL 数据增删改查综合案例
好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
随机推荐
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
玖逸云黑免费无加密版本源码
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
Richview trvstyle liststyle list style (bullet number)
simpleParallax. JS (create poor visual effects for website pictures)
八大排序
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Dlopen() implements dynamic loading of third-party libraries
Qt学习19 Qt 中的标准对话框(上)
Reflection -- basic usage
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
Redis:字符串类型数据的操作命令
Use vscode to view hex or UTF-8 codes
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
JS first summary
JVM family - overview, program counter day1-1
JVM runtime data area
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;