# OJ第六批——Problem D: A代码完善--系统日期

## Problem D: A代码完善--系统日期

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 173  Solved: 80
[Submit][Status][Web Board]

# 注：本题只需要提交填写部分的代码，请按照C++方式提交。

#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;
class Date
{
public:
Date(int year,int month,int day):year(year),month(month),day(day) {}
Date(const Date &d)
{
this->year=d.year;
this->month=d.month;
this->day=d.day;
}
protected:
int year;
int month;
int day;
};

class Time
{
public:
Time(int hour,int minute,int seconds):hour(hour),minute(minute),seconds(seconds) {}
Time(const Time &t)
{
this->hour=t.hour;
this->minute=t.minute;
this->seconds=t.seconds;
}
protected:
int hour;
int minute;
int seconds;
};
/*************************
在此处补充和修改你的代码
class DateTime :protected Date,protected Time
{
public:
DateTime(Date &d, Time &t )
void show()
};
**************************/
int main()
{
int year,month,day;
cin>>year>>month>>day;
Date d1(year,month,day);
int hour,minute,seconds;
cin>>hour>>minute>>seconds;
Time t1(hour,minute,seconds);
DateTime dt(d1,t1);
dt.show();
return 0;
}

## Sample Input

2014 7 10 10 30 15

## Sample Output

071010302014.15

## HINT

#include <iostream> 
#include <stdio.h> 
#include <iomanip> 
using  namespace std;
class  Date 
{
public: 
    Date(int year,int  month,int day):year(year),month(month),day(day) {} 
    Date(const Date &d)
    { 
        this->year=d.year; 
        this->month=d.month; 
        this->day=d.day; 
    } 
protected: 
    int year;
    int month;
    int day;
};

class Time
{
public: 
    Time(int hour,int  minute,int seconds):hour(hour),minute(minute),seconds(seconds) {} 
    Time(const Time &t)
    { 
        this->hour=t.hour; 
        this->minute=t.minute; 
        this->seconds=t.seconds; 
    } 
protected: 
    int hour;
    int minute;
    int seconds;
};
class DateTime :public Date,public  Time 
{
public: 
    DateTime(Date &d, Time &t):Date(d),Time(t) {} 
    void show();

};

void  DateTime::show() 
{
    cout<<setfill('0')<<setw(2)<<month<<setfill('0')<<setw(2)<<day<<setfill('0')<<setw(2)<<hour<<setfill('0')<<setw(2)<<minute; 
    cout<<setfill('0')<<setw(4)<<year<<"."; 
    cout<<setfill('0')<<setw(2)<<seconds<<endl; 
}

int  main() 
{
    int year,month,day;
    cin>>year>>month>>day; 
    Date d1(year,month,day); 
    int hour,minute,seconds;
    cin>>hour>>minute>>seconds; 
    Time t1(hour,minute,seconds); 
    DateTime dt(d1,t1); 
    dt.show(); 
    return 0;
}

07-21 673

07-21 799

07-21 703

07-21 694

07-21 584

07-21 740

07-21 711

07-21 410

07-21 739

05-16 703

#### YTU-OJ-构造函数和析构函数

©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。