输入的第一个整数n,表示有n组测试数据。
后面的输入每行为一组测试数据。每组测试数据的前3个整数是日期的年月日,后3个整数是时间的时分秒。
每组测试数据对应一行输出。日期的输出格式为“yyyy-mm-dd”,时间的输出格式为“hh:mm:ss”,中间用一个空格分开。
한국어< 中文 فارسی English ไทย All Copyright Reserved 2010-2011 SDUSTOJ TEAM GPL2.0 2003-2011 HUSTOJ Project TEAM Anything about the Problems, Please Contact Admin:admin
#include<iostream> #include<iomanip> using namespace std; class Date{ public: Date(int newy,int newm,int newd); void showDate(); private: int year,month,day; }; Date::Date(int newy,int newm,int newd){ year = newy; month = newm; day = newd; } inline void Date::showDate(){ cout << setw(4) << setfill('0') << year << "-" << setw(2) << setfill('0') << month << "-" << setw(2) << setfill('0') << day ; } class Time{ public: Time(int newh,int newm,int news); void showTime(); private: int hour,minute,second; }; Time::Time(int newh,int newm,int news){ hour = newh; minute = newm; second = news; } inline void Time::showTime(){ cout << setw(2) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << ":" << setw(2) << setfill('0') << second ; } int main() { int cases; cin >> cases; for(int ca = 0; ca < cases; ca++) { int year, month, day; cin >> year >> month >> day; Date date(year, month, day); date.showDate(); cout << " "; int hour, minute, second; cin >> hour >> minute >> second; Time time(hour, minute, second); time.showTime(); cout << endl; } }