Как организовано размещение данных в памяти в данном коде
#include <iostream>
#include "cmath";
#include "Windows.h"
using namespace std;
struct Students
{
string surname, name, group;
int studentCard;
};
void output(Students** st, int size) {
for (int i = 0; i < size; i++)
{
cout << i + 1 << " student " << endl;
cout << "Surname " << st[i]->surname << endl;
cout << "Name " << st[i]->name << endl;
cout << "Group " << st[i]->group << endl;
cout << "Student card " << st[i]->studentCard << endl;
cout << "------------------" << endl;
}
}
bool compareByName(Students** st, int first, int second) {
int i = 0, j = 0;
while (true) {
if (st[first]->name == st[second]->name) return false;
if (st[first]->name[i] < st[second]->name[j]) return false;
if (st[first]->name[i] > st[second]->name[j]) return true;
if (i == st[first]->name.length() && j != st[second]->name.length()) return true;
if (i != st[first]->name.length() && j > st[second]->name.length()) return false;
i++; j++;
}
}
bool compareBySecondName(Students** st, int first, int second) {
int i = 0, j = 0;
while (true) {
if (st[first]->surname == st[second]->surname) return compareByName(st, first, second);
if (st[first]->surname[i] < st[second]->surname[j]) return false;
if (st[first]->surname[i] > st[second]->surname[j]) return true;
if (i == st[first]->surname.length() && j != st[second]->surname.length()) return true;
if (i != st[first]->surname.length() && j > st[second]->surname.length()) return false;
i++; j++;
}
}
bool isFirstBiggerThanSecond(Students** st, int first, int second) {
int i = 0, j = 0;//hello hello
while (true) {
if (st[first]->group == st[second]->group) return compareBySecondName(st, first, second);
if (st[first]->group[i] < st[second]->group[j]) return false;
if (st[first]->group[i] > st[second]->group[j]) return true;
if (i == st[first]->group.length() && j != st[second]->group.length()) return true;
if (i != st[first]->group.length() && j > st[second]->group.length()) return false;
i++; j++;
}
}
void sortArray(Students** st, int size) {
for (int i = 0, k = 0; i < size; i++)
{
for (int j = i + 1; j < size; j++)
{
if (isFirstBiggerThanSecond(st, i, j)) {
Students* temp = st[i];
st[i] = st[j];
st[j] = temp;
}
}
}
}
void fillArray(Students** st, int size) {
for (int i = 0; i < size; i++)
{
cout << "Input a surname "; cin >> st[i]->surname;
cout << "Input a name "; cin >> st[i]->name;
cout << "Input a group "; cin >> st[i]->group;
cout << "Input a student card "; cin >> st[i]->studentCard;
}
}
int main()
{
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
int size;
cout << "Enter size ";
cin >> size;
Students** st = new Students * [size];
for (int i = 0; i < size; i++)
{
st[i] = new Students;
}
fillArray(st, size);
sortArray(st, size);
output(st, size);
system("pause");
}
Если не сложно, то продемонстрируйте графически для полного понимания