(直接存取类线性表4.7.1)POJ 3751 时间日期格式转换(24小时制转换成12小时制)
2013-10-26 22:08
330 查看
/* * POJ_3751.cpp * * Created on: 2013年10月25日 * Author: Administrator */ #include <iostream> #include <cstdio> using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int year,month,day,hour,minute,second; scanf("%d/%d/%d-%d:%d:%d",&year,&month,&day,&hour,&minute,&second); //24小时制与12小时制的差别就在于hour和am、pm的区别上 int hour1; if(hour == 0){//如果是0点就转换成12点 hour1 = 12; }else{ hour1 = (hour>12)?hour-12:hour; } cout<<(month < 10?"0" :"")<<month<<"/"<<(day < 10?"0" :"")<<day<<"/"<<year<<"-"<<(hour1 < 10?"0" :"")<<hour1<<":"<<(minute < 10?"0" :"")<<minute<<":"<<(second < 10?"0" :"")<<second<<(hour>=12?"pm":"am")<<endl; } return 0; }
相关文章推荐
- POJ-3751 时间日期格式转换-24小时制/12小时制
- poj 3751 时间日期格式转换
- poj 3751 时间日期格式转换
- (应用直接存取类线性表4.1.1)POJ 2080 Calendar(日期计算)
- (直接存取类线性表4.1.2)UVA 602 - What Day Is It?(数组的应用---日期系统的转换)
- POJ 3751 时间日期格式转换
- poj 3751 时间日期格式转换
- poj 3751 时间日期格式转换
- POJ 3751 时间日期格式转换
- poj 3751 时间日期格式转换
- POJ3751 时间日期格式转换
- poj 3751 时间日期格式转换 水题
- poj 3751时间日期格式转换
- POJ 3751 时间日期格式转换
- mysql 将时间戳直接转换成日期时间,mysql查询某一天的数据。
- mysql 将时间戳直接转换成日期时间
- mysql 将时间戳直接转换成日期时间
- mysql 将时间戳直接转换成日期时间
- C 输入24小时制的时间转换为12小时制得时间,暂不考虑错误处理
- mysql 将时间戳直接转换成日期时间