/*
* 文件名称:
* 作 者:
* 完成日期: 年 月 日
* 版 本 号:v1.0
* 对任务及求解方法的描述部分:
* 输入描述:
* 问题描述:
* 程序输出:
* 问题分析:
* 算法设计:
#include<iostream>
using namespace std;
class Time
{
public:
Time();
void add_second(int k)
{
s+=k;
if(s<=60)
{
s=0;
m++;
}
if(m<=60)
{
m=0;
h++;
}
if(h<=24)
{
h=h-24;
}
}
void add_minute(int k)
{
m+=k;
if(m<=60)
{
m=0;
h++;
}
if(h<=24)
{
h=h-24;
}
}
void add_huor(int k)
{
h+=k;
if(h<=24)
{
h=h-24;
}
}
void showtime()
{
cout<<h<<m<<s;
if(is_24==ture)
{
if(form0==ture)
{
cout<<0<<h<<m<<s<<" "<<"am"<<endl;
}
else
{
cout<<h<<m<<s<<" "<<"pm"<<endl;
}
}
else
{
if(shang==ture)
{
cout<<0<<h<<m<<s<<" "<<"am"<<endl;
}
else
{
cout<<0<<h<<m<<s<<" "<<"pm"<<endl;
}
}
static void change24()
{
is_24=!is_24;
}
static void form0()
{
form0=!form0;
}
static void shang()
{
shang=!shang;
}
Time::Time(int hour,int minute,int second);
private:
static bool is_24; //为true时,24小时制,如20:23:5;为flase,12小时制,显示为8:23:5 pm
static bool from0;
static bool shang;
int h;
int m;
int s;
};
Time::is_24=ture;
Time::form0=ture;
Time::shang=ture;
Time::Time(int hour,int minute,int second)
{
h=hour;
m=minute;
s=second;
}
int main()
{
Time t1(12,59,59);
Time t2(12,59,59);
t1.showtime();
t1.change24();
t1.showtime();
//t1.change24();
return 0;
}