• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
若忆_star
博客园    首页    新随笔    联系   管理    订阅  订阅
poj 3751 时间日期格式转换

题目链接:http://poj.org/problem?id=3751

题目大意:按照要求的格式将输入的时间日期进行转化。

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 int main ()
 5 {
 6     int t;
 7     cin>>t;
 8     while (t--)
 9     {
10         int y,m,d,xs,fz,ms;
11         char ch1,ch2,ch3,ch4,ch5;
12         //scanf("%d/%d/%d-%d:%d:%d",y,m,d,xs,fz,ms);
13         //printf ("%d/%d/%d-%d:%d:%d",m,d,y,xs,fz,ms);
14         scanf("%d%c%d%c%d%c%d%c%d%c%d",&y,&ch1,&m,&ch2,&d,&ch3,&xs,&ch4,&fz,&ch5,&ms);
15         char q,p;
16         if (xs>=12)
17         {
18             q='p';
19             p='m';
20         }
21         else
22         {
23             q='a';
24             p='m';
25         }
26         if (xs==0)
27             xs=12;
28         xs=(xs>12?xs-12:xs);
29            printf ("%02d/%02d/%04d-%02d:%02d:%02d%c%c\n",m,d,y,xs,fz,ms,q,p);
30     }
31     return 0;
32 }

 

posted on 2014-07-10 15:13  若忆_star  阅读(273)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3