forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.cpp
51 lines (48 loc) · 918 Bytes
/
Solution.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class Person {
public:
string name;
int age;
virtual void getdata() {}
virtual void putdata() {}
};
class Professor: public Person {
public:
Professor () {
id++;
cur_id = id;
}
int publications;
int cur_id;
static int id;
virtual void getdata() {
cin >> name >> age >> publications;
}
virtual void putdata() {
cout << name << " " << age << " " << publications << " " << cur_id << "\n";
}
};
int Professor::id = 0;
class Student: public Person {
public:
Student () {
id++;
cur_id = id;
}
int cur_id;
static int id;
int marks[6];
virtual void getdata() {
cin >> name >> age;
for (int i = 0; i < 6; ++i) {
cin >> marks[i];
}
}
virtual void putdata() {
int sum = 0;
for (int i = 0; i < 6; ++i) {
sum += marks[i];
}
cout << name << " " << age << " " << sum << " " << cur_id << "\n";
}
};
int Student::id = 0;