现在的位置: 首页 > 综合 > 正文

OJ17

2014年09月05日 ⁄ 综合 ⁄ 共 797字 ⁄ 字号 评论关闭

#include <iostream>

using namespace std;
class Time;
class Date
{public :
Date(){}
Date(int y,int m,int d):year(y),month(m),day(d){}
friend  void display(const Date &,const Time &);

int getyear()
{
    return year;
}

int getmonth()
{
    return month;
}
int getday()
{
    return day;
}
private:
int year,month,day;

 

};
class Time
{public :
Time(){}
Time(int h,int m,int s):hour(h),minute(m),second(s){}

 

friend  void display(const Date &,const Time &);

private:

int hour,minute,second;

 

};

 

void display(const Date &d,const Time &t)
{
    cout<<d.year<<"/"<<d.month<<"/"<<d.day<<endl;
    cout<<t.hour<<":"<<t.minute<<":"<<t.second<<endl;

}
int main()

{

    void display(const Date &,const Time &);

    int year,month,day;

    cin>>year>>month>>day;

    Date d1(year,month,day);

    int hour,minute,second;

    cin>>hour>>minute>>second;

    Time t1(hour,minute,second);

    display(d1,t1);

    return 0;

}

 

抱歉!评论已关闭.