Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <string>
- using namespace std;
- class Persona
- {
- public:
- virtual void Show() = 0;
- virtual int Age(int year, int month, int day) = 0;
- };
- class Enrolle: public Persona
- {
- protected:
- string Surname;
- int DOB;
- string Faculty;
- public:
- Enrolle(): Surname("."), DOB(00000000), Faculty(".")
- {
- }
- Enrolle(string a, int x, string b): Surname(a), DOB(x), Faculty(b)
- {
- }
- void Show()
- {
- cout << Surname << "/n" << DOB/1000000 << "." << DOB%1000000/10000 <<"." << DOB%10000 << "/n" << Faculty << endl;
- }
- int Age(int year, int month, int day)
- {
- if (DOB%1000000/10000 < month) return year + 1900 - DOB%10000;
- else if(DOB%1000000/10000 == month)
- {
- if (DOB/1000000 <= day) return year + 1900 - DOB%10000;
- else return year + 1899 - DOB%10000;
- }
- else return year + 1899 - DOB%10000;
- }
- };
- class Student: public Persona
- {
- protected:
- string Surname;
- int DOB;
- string Faculty;
- int Cours;
- public:
- Student(): Surname("."), DOB(00000000), Faculty("."), Cours(0)
- {
- }
- Student(string a, int x, string b, int c): Surname(a), DOB(x), Faculty(b), Cours(c)
- {
- }
- void Show()
- {
- cout << Surname << "/n" << DOB/1000000 << "." << DOB%1000000/10000 <<"." << DOB%10000 << "/n"
- << Faculty << "/n" << Cours << endl;
- }
- int Age(int year, int month, int day)
- {
- if (DOB%1000000/10000 < month) return year + 1900 - DOB%10000;
- else if(DOB%1000000/10000 == month)
- {
- if (DOB/1000000 <= day) return year + 1900 - DOB%10000;
- else return year + 1899 - DOB%10000;
- }
- else return year + 1899 - DOB%10000;
- }
- };
- class Teacher: public Persona
- {
- protected:
- string Surname;
- int DOB;
- string Faculty;
- string Post;
- int Experience;
- public:
- Teacher(): Surname("."), DOB(00000000), Faculty("."), Post("."), Experience(0)
- {
- }
- Teacher(string a, int x, string b, string d, int e): Surname(a), DOB(x), Faculty(b), Post(d), Experience(e)
- {
- }
- void Show()
- {
- cout << Surname << "/n" << DOB/1000000 << "." << DOB%1000000/10000 <<"." << DOB%10000 << "/n" << Faculty
- << "/n" << Post << "/n" << Experience << endl;
- }
- int Age(int year, int month, int day)
- {
- if (DOB%1000000/10000 < month) return year + 1900 - DOB%10000;
- else if(DOB%1000000/10000 == month)
- {
- if (DOB/1000000 <= day) return year + 1900 - DOB%10000;
- else return year + 1899 - DOB%10000;
- }
- else return year + 1899 - DOB%10000;
- }
- };
- using namespace std;
- int main()
- {
- time_t t = time(0);
- struct tm now;
- localtime_s(&now,&t);
- /* int age = 1996;
- int year = now.tm_year + 1900 - age;
- cout << year;*/
- setlocale( LC_ALL, "Russian");
- Persona *Human [9];
- Human[0] = new Enrolle("Аванесян", 12091996, "КНИИТ");
- Human[1] = new Student("Бескровнов", 12031996, "КНИИТ", 1);
- Human[2] = new Teacher("Болдырев", 9091972, "КНИИТ","Teacher", 7);
- Human[3] = new Enrolle("Гараничева", 3081945, "КНИИТ");
- Human[4] = new Student("Добрынин", 18052014, "КНИИТ", 1);
- Human[5] = new Teacher("Дьяячков", 19051934, "КНИИТ", "Teacher", 8);
- Human[6] = new Enrolle("Елисеева", 17051967, "КНИИТ");
- Human[7] = new Student("Еремушкин", 30041989, "КНИИТ", 2);
- Human[8] = new Teacher("Ермолаев", 16081996, "КНИИТ", "Teacher", 2);
- Human[9] = new Enrolle("Зажарнов", 12091996, "КНИИТ");
- for(int i = 0; i<10; i++)
- {
- Human[i]->Show();
- }
- int a, b;
- cout << "Ener the age range ";
- cin >> a >> b;
- for(int i = 0; i < 1; i++)
- {
- if (Human[i]->Age(now.tm_year, now.tm_mon, now.tm_mday) > a &&
- Human[i]->Age(now.tm_year, now.tm_mon, now.tm_mday) < b)
- Human[i]->Show();
- }
- //struct tm {
- // int tm_sec; /* seconds after the minute - [0,59] */
- // int tm_min; /* minutes after the hour - [0,59] */
- // int tm_hour; /* hours since midnight - [0,23] */
- // int tm_mday; /* day of the month - [1,31] */
- // int tm_mon; /* months since January - [0,11] */
- // int tm_year; /* years since 1900 */
- // int tm_wday; /* days since Sunday - [0,6] */
- // int tm_yday; /* days since January 1 - [0,365] */
- // int tm_isdst; /* daylight savings time flag */
- // };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement