Add main_students in projects
Этот коммит содержится в:
@@ -39,6 +39,7 @@
|
||||
<Unit filename="lab04.h" />
|
||||
<Unit filename="main.cpp" />
|
||||
<Unit filename="source.cpp" />
|
||||
<Unit filename="students.cpp" />
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
|
||||
21
lab04.h
21
lab04.h
@@ -4,6 +4,7 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#pragma once
|
||||
|
||||
void print_in_hex(uint8_t byte);
|
||||
@@ -13,4 +14,24 @@ void print_in_binary(const void* data, size_t size);
|
||||
uint16_t perform_bitwise_operation(uint16_t operand1, char operation, uint16_t operand2);
|
||||
void print_calculation(uint16_t result);
|
||||
|
||||
// Student
|
||||
struct Student {
|
||||
char name[17];
|
||||
uint16_t admissionYear;
|
||||
float averageGrade;
|
||||
unsigned int gender : 1;
|
||||
unsigned int completedCourses;
|
||||
Student* groupLeader;
|
||||
|
||||
// Initialisation
|
||||
Student(const char* n, uint16_t year, float grade, unsigned int g, unsigned int courses, Student* leader)
|
||||
: admissionYear(year), averageGrade(grade), gender(g), completedCourses(courses), groupLeader(leader)
|
||||
{
|
||||
strncpy(name, n, sizeof(name) - 1);
|
||||
name[sizeof(name) - 1] = '\0';
|
||||
}
|
||||
};
|
||||
|
||||
void printStudentDetails(const Student& student);
|
||||
|
||||
#endif // LAB04_H_INCLUDED
|
||||
|
||||
17
main.cpp
17
main.cpp
@@ -43,3 +43,20 @@ int main_calc(){
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main_students() {
|
||||
// Student
|
||||
Student students[3] = {
|
||||
Student("Alice", 2019, 4.5, 0, 3, nullptr),
|
||||
Student("Bob", 2019, 4.2, 1, 2, nullptr),
|
||||
Student("Charlie", 2019, 4.7, 1, 4, nullptr) // Îáðàòèòå âíèìàíèå, ÷òî òóò íåò óêàçàòåëÿ íà groupLeader
|
||||
};
|
||||
|
||||
// Details
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
std::cout << "\nDetails of Student " << i + 1 << ":" << std::endl;
|
||||
printStudentDetails(students[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "lab04.h"
|
||||
#include "calc_bits.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user