diff --git a/1.cpp b/1.cpp new file mode 100644 index 0000000..6f0bf94 --- /dev/null +++ b/1.cpp @@ -0,0 +1,32 @@ +#include +#include +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; +}