#include<iostream>
#include<string>
using namespace std;
using std::string;
/*这是一个用于人事管理的题,要求核对身份证号和生日信息,可我写的只能循环一次,求问怎么改才能循环*/
class Date
{
	public:
		/*Date(int y,int m,int d)
		{
			year=y;
			month=m;
			day=d;
		}*/
		void set()
		{
			
			cout<<"年:";
			cin>>year;
			
			cout<<"月:";
			cin>>month;
			
			cout<<"日:"; 
			cin>>day;
		}
		void show()
		{
			cout<<"出生日期:"<<year<<"年"<<month<<"月"<<day<<"日"<<endl; 
		}
		
		string getYear()
		{
			return year;
		}
		string getMonth()
		{
			return month;
		}
		string getDay()
		{
			return day;
		}
	private:
		string year;
		string month;
		string day;
		
};
class Person
{
	public:
		/*Person(int num,string s,Date b,int id)
		:number(num),sex(s),birthday(b),ID(id)
		{
			number=num;
			sex=s;
			birthday=b;
			ID=id;
		}*/
		void set();
		void show();
		string getID()
		{
			return ID;
		}
		string getY()
		{
			return birthday.getYear();
		}
		string getM()
		{
			return birthday.getMonth();
		}
		string getD()
		{
			return birthday.getDay();
		}
	private:
		int number;
		string sex;
		Date birthday;
		string ID;
		
};
void Person::set()
{
	cout<<"输入编号:";
	cin>>number;
	cout<<"输入性别:";
	cin>>sex; 
	cout<<"输入出生日期:"<<endl;
	birthday.set();
	cout<<"输入身份证号:";
	cin>>ID; 	
}
void Person::show()
{
	cout<<"编号:"<<number;
	cout<<"性别:"<<sex;
	birthday.show();
	cout<<"身份证号:"<<ID; 
}
int main()
{
	Person p;
	p.set();
	string id=p.getID();
	char c;
	string yy=p.getY();
	string mm=p.getM();
	string dd=p.getD();
	string y=id.substr(6,4);
	string m=id.substr(10,2);
	string d=id.substr(12,2);
	
	if(y==yy && m==mm && d==dd)
	{
		p.show();
		cout<<"是否确定录入?"<<endl;
		cout<<"Y or N"<<endl;
		cin>>c;
		while(c=='N')
		{
			Person p1;
			p1.set();
		}
	}
	else
	{
		cout<<"输入错误!请重新输入:"<<endl;
		p.set(); 
	}
	
	return 0;
}