There is here a small program, which in theory should display the most frequently entered name and the number of its repetitions. But when doing it, it just crashes. Please help.
int main(int argc, char** argv) { russian(); //отдельная функция в заголовочном файле, не обращайте внимания vector<string> strings; string current = " "; string max = " "; int nmax = 0; int count = 0; cout << "Введите последовательность имён "; while(cin >> current) { strings.push_back(current); } sort(strings.begin(), strings.end()); current = " "; for(int i = 0; i < strings.size(); ++i){ if(current == strings[i]) { ++count; } else { if(count >= nmax) { nmax = count; max = strings[i - 1]; } else { current = strings[i]; count = 0; } } } cout << "\nКоличество повторений: " << nmax << "\nИмя повторяющееся наибольшее количество раз: " << max; return 0; }