Поясните пожалуйста код С++ int main()
{
train* arrayOfTrain[5];
for (int i = 0; i < 5; i++)
{
string punkt;
int trainNumber;
Time startTime;
cin >> punkt;
cin >> trainNumber;
cin >> startTime;
arrayOfTrain[i] = new train(punkt, trainNumber, startTime);
}

for (int i = 0; i < 5 - 1; i++)
for (int j = i + 1; j < 5; j++) {
if (strcmp(arrayOfTrain[i]->punkt.c_str(), arrayOfTrain[j]->punkt.c_str()) > 0)
{
swap(arrayOfTrain[i], arrayOfTrain[j]);
}
}

for (int i = 0; i < 5 - 1; i++)
for (int j = i + 1; j < 5; j++) {
if (strcmp(arrayOfTrain[i]->punkt.c_str(), arrayOfTrain[j]->punkt.c_str()) == 0)
{
if (arrayOfTrain[i]->startTime.m_hours > arrayOfTrain[j]->startTime.m_hours)
swap(arrayOfTrain[i], arrayOfTrain[j]);
if (arrayOfTrain[i]->startTime.m_hours == arrayOfTrain[j]->startTime.m_hours)
if (arrayOfTrain[i]->startTime.m_minutes > arrayOfTrain[j]->startTime.m_minutes)
swap(arrayOfTrain[i], arrayOfTrain[j]);
}
}

for (int i = 0; i < 5; i++)
{
cout << arrayOfTrain[i]->punkt << " " << arrayOfTrain[i]->trainNumber << " " << arrayOfTrain[i]->startTime << endl;
}
system("pause");
return 0;
}
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Copyright © 2024 SCHOLAR.TIPS - All rights reserved.