main
p2jvg4k7s 5 months ago
parent 09faded414
commit fc41971171

32
1.cpp

@ -0,0 +1,32 @@
#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;
}
Loading…
Cancel
Save