#include <iostream>
#include <iomanip>
#include <bitset>
#include <cstddef>

struct Student {
    char name[17];
    uint16_t year_of_admission;
    float average_score;
    unsigned int gender : 1;
    unsigned int completed_courses;
    Student* group_leader;
};

void print_in_hex(const void* data, size_t size) {
    const unsigned char* byte_data = reinterpret_cast<const unsigned char*>(data);
    for (size_t i = 0; i < size; ++i) {
        std::cout << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(byte_data[i]) << " ";
    }
    std::cout << std::dec << "\n";
}

void print_student(const Student& student) {
    std::cout << "Name: " << student.name << "\n";
    std::cout << "Year of Admission: " << student.year_of_admission << "\n";
    std::cout << "Average Score: " << student.average_score << "\n";
    std::cout << "Gender: " << student.gender << "\n";
    std::cout << "Completed Courses: " << student.completed_courses << "\n";
    std::cout << "Group Leader: " << student.group_leader << "\n\n";
}

int main() {
    Student group_leader = { "Smirnov Ivan", 2023, 4.8, 1, 13, nullptr };
    Student student1 = { "Tihonov Pavel", 2024, 4.5, 1, 3, &group_leader };
    Student student2 = { "Kyznecova Maria", 2022, 4.2, 0, 22, &group_leader };
    Student students[] = { group_leader, student1, student2 };

    std::cout << "Address of array: " << &students << "\n";
    std::cout << "Size of array: " << sizeof(students) << " bytes\n\n";

    for (int i = 0; i < 3; ++i) {
        std::cout << "Address of students[" << i << "]: " << &students[i] << "\n";
        std::cout << "Size of students[" << i << "]: " << sizeof(students[i]) << " bytes\n";
    }
    std::cout << "\n";

    // Информация для не старосты (student1)
    std::cout << "Address of student1.name: " << static_cast<void*>(student1.name) << "\n";
    std::cout << "Offset of name: " << offsetof(Student, name) << "\n";
    std::cout << "Size of name: " << sizeof(student1.name) << "\n";
    print_in_hex(student1.name, sizeof(student1.name));

    std::cout << "\nHex representation of all array elements:\n";
    print_in_hex(students, sizeof(students));

    return 0;
}
