using namespace std;
struct Employee {
string name;
int accessLevel;
float salary;
int contractPeriod;
Employee* boss;
};
void findBoss(Employee* employees, int n) {
for (int i = 0; i < n; i++) {
Employee* current = &employees[i];
while (current->boss != nullptr) {
current = current->boss;
}
cout << "Boss for " << employees[i].name << " is " << current->name << ", access level: " << current->accessLevel << endl;
}
}
int main() {
int n = 3;
Employee* employees = new Employee[n];
employees[0] = {"John", 10, 5000, 12, nullptr};
employees[1] = {"Anna", 8, 4000, 6, &employees[0]};
employees[2] = {"Peter", 6, 3000, 3, &employees[1]};
findBoss(employees, n);
}