#include #include using namespace std; struct Person { string name; int ID; int Year_Born; int Month_Born; int Day_Born; }; void getinfo(Person*); //void printinfo(Person*); int comparePerson(Person*, Person*); int main(){ Person *p1, *p2; int n; p1=new Person; p2=new Person; getinfo(p1); getinfo(p2); n=comparePerson(p1,p2); if(n<0){ cout<<"first person, "<name<<", is older\n"; } else if (n==0){ cout<<"Both persons have the same B'day\n"; } else{ cout<<"second person, "<name<<", is older\n"; } } void getinfo(Person* p) { cout<<"Enter name(string)\n"; cin>>p->name; cout<<"Enter ID(int)\n"; cin>>p->ID; cout<<"Enter Year_Born\n"; cin>>p->Year_Born; cout<<"Enter Month_Born\n"; cin>>p->Month_Born; cout <<"Enter Day_Born\n"; cin>>p->Day_Born; } int compareYear(Person *p1,Person *p2) { return p1->Year_Born - p2->Year_Born; } int compareMonth(Person *p1,Person *p2) { return p1->Month_Born - p2->Month_Born; } int compareDay(Person *p1,Person *p2) { return p1->Day_Born - p2->Day_Born; } int comparePerson(Person* p1, Person* p2) { if (p1->Year_Born != p2->Year_Born) return compareYear(p1,p2); else if (p1->Month_Born != p2->Month_Born) return compareMonth(p1,p2); else return compareDay(p1,p2); }