You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
610 B
33 lines
610 B
#include <iostream>
|
|
#include <iomanip>
|
|
using namespace std;
|
|
class Time
|
|
{
|
|
public:
|
|
void setTime();
|
|
void showTime();
|
|
int hour, minute, sec;
|
|
};
|
|
|
|
void Time::setTime()
|
|
{ cin>>hour>>minute>>sec; }
|
|
|
|
void Time::showTime()
|
|
{
|
|
if(hour>24||minute>60||sec>60)
|
|
{
|
|
cout<<"input error, plz input again";
|
|
return;
|
|
}
|
|
cout << setw(2) << right << setfill('0') << hour<<":";
|
|
cout << setw(2) << right << setfill('0') << minute<<":";
|
|
cout << setw(2) << right << setfill('0') << sec;
|
|
}
|
|
|
|
int main()
|
|
{ Time t;
|
|
t.setTime();
|
|
t.showTime();
|
|
return 0;
|
|
}
|