#include<iostream>
#include<string>
#include<iomanip>
#include<stdexcept>
using namespace std;
class Time
{
private:
    int h,m,s;
public:
    Time(int hour=0,int minute=0,int second=0);
    void settime(const int hour,const int minute,const int second);
    void displaytime24();
    void displaytime12();
};
Time::Time(int hour,int minute,int second)
:h(hour),m(minute),s(second){}

void Time::settime(const int hour,const int minute,const int second)
{

    h=hour;
    m=minute;
    s=second;
    if(h<0 || h>23)
       {
           
        throw runtime_error("hourout");
    }

}
void Time::displaytime24()
{
    cout<<h<<":"<<m<<":"<<s<<endl;
}
void Time::displaytime12()
{
    int g,t;
    if(h>12 && h<24)
    {
        t=1;
    }
    else
    {
        t=0;
    }
    
    if((1) || h==24 )
    {
        g=h-12;
        cout<<g<<":"<<m<<":"<<s;
    }
    else
        cout<<h<<":"<<m<<":"<<s;
    
    if( (1) || h==12)
        cout<<" PM"<<endl;
    else
        cout<<" AM"<<endl;
}
int main()
{
    int h;
    try {
        cout<<"hour: ";
        cin>>h;
    }
    catch(exception &e)
    {
        cout<<"Exceptions: "<<e.what()<<endl;
    }
    Time T(21,22,11);
    T.displaytime24();
    T.displaytime12();
}
