注意:不要把12:00显示成0:00。
本题采用午夜12点显示为AM,中午12点为PM的规定。
#include "stdafx.h"
#include"iostream"
#include <stdio.h>
#include <stdlib.h>
#include "math.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char s[10];
scanf("%s",s);
int h,m,flag=0;
h=(s[0]-48)*10+s[1]-48;
if(h>12)
{
h=h-12;
flag=1;
}
cout<<h<<":"<<s[3]<<s[4];
if(flag==0)
cout<<"AM"<<endl;
else
cout<<"PM"<<endl;
return 0;
}