编写一个程序,要求用户输入24小时制的时间,然后显示12小时制的时间,如输入12:09,输出12:9 PM。注意,在英文的习惯中,中午12点被认为是下午, 而0点被认为是第二天的时间,所以输出是0:0 AM;此外,输出时当小时或分钟数小于10时,均没有前导的零。
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<<"...
如图