Ку. Короче, такая проблема Есть код, который сортирует список людей по фамилиям в алфавитном порядке. Список содержит фамилию, имя и отчество. Проблема в том, что если у людей одинаковая Фамилия, код не переходит к сравниванию имени и отчества, а как бы это нужно. Я так и не придумал, как это реализовать. Ввод и вывод - через файл. Отблагодарю копеечкой за помощь. Мой код: #include "fstream" #include "string" #include "iostream" #include "iomanip" using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); struct student{ string F, I, O; void print(); }; void student::print(){ out << F << ' ' << I << ' ' << O << endl; } void sort(student *a, int n){ student temp; for (int i = 1; i <= n; i++){ int j = i; while (a[j - 1].F.compare(a[j].F)>0){ temp = a[j]; a[j] = a[j - 1]; a[j - 1] = temp; j--; } } } int main(){ int n = 0; student a[20]; while (in.peek() != EOF){ in >> a[n].F >> a[n].I >> a[n].O; cout<<a[n].F; n++; } sort(a, n); for (int i = 0; i <= n; i++){ a[i].print(); } in.close(); out.close(); return 0; } C #include "fstream" #include "string" #include "iostream" #include "iomanip" using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); struct student{ string F, I, O; void print(); }; void student::print(){ out << F << ' ' << I << ' ' << O << endl; } void sort(student *a, int n){ student temp; for (int i = 1; i <= n; i++){ int j = i; while (a[j - 1].F.compare(a[j].F)>0){ temp = a[j]; a[j] = a[j - 1]; a[j - 1] = temp; j--; } } } int main(){ int n = 0; student a[20]; while (in.peek() != EOF){ in >> a[n].F >> a[n].I >> a[n].O; cout<<a[n].F; n++; } sort(a, n); for (int i = 0; i <= n; i++){ a[i].print(); } in.close(); out.close(); return 0; }