輸入六個正整數,中間以空格隔開,分別表示年月日,小時,分,秒。
第一行為年月日,中間以空格隔開,第二行為時分秒,中間以冒號隔開。
#include<iostream>
using namespace std;
class Time
{
public:
Time()
{
year=0;
mouth=0;
day=0;
hour=0;
minute=0;
second=0;
}
void setBtime(int newy,int newmo,int newd);
void setStime(int newh,int newmi,int news);
void showBtime();
void showStime();
private:
int year,mouth,day,hour,minute,second;
};
void Time::setBtime(int newy,int newmo,int newd)
{
year=newy;
mouth=newmo;
day=newd;
}
void Time::setStime(int newh,int newmi,int news)
{
hour=newh;
minute=newmi;
second=news;
}
inline void Time::showBtime()
{
cout<<year<<" "<<mouth<<" "<<day<<endl;
}
inline void Time::showStime()
{
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
int main()
{
Time myBtime,myStime;
int y,mo,d,h,mi,se;
cin>>y>>mo>>d>>h>>mi>>se;
myBtime.setBtime(y,mo,d);
myStime.setStime(h,mi,se);
myBtime.showBtime();
myStime.showStime();
return 0;
}