есть такой код: #include <iostream> #include "windows.h" #include <fstream> #include <vector> #include <string> #ifdef _WIN32 #define CLEAR_SCREEN "cls" #else #define CLEAR_SCREEN "clear" #endif using namespace std; struct Answer { string name; vector<string> responses; }; int main() { setlocale(LC_ALL, ""); SetConsoleCP(1251); SetConsoleOutputCP(1251); int numQuestions, numParticipants; cout << "Введите количество задаваемых вопросов: "; cin >> numQuestions; cout << "\n"; cin.ignore(); vector<string> questions(numQuestions); for (int i = 0; i < numQuestions; ++i) { cout << "Введите вопрос #" << i + 1 << ": "; getline(cin, questions[i]); } cout << "\n" << "Введите количество участников опроса: "; cin >> numParticipants; cin.ignore(); vector<Answer> participants(numParticipants); for (int i = 0; i < numParticipants; ++i) { system(CLEAR_SCREEN); cout << "\nВведите ваше имя: "; getline(cin, participants[i].name); participants[i].responses.resize(numQuestions); for (int j = 0; j < numQuestions; ++j) { cout << "\n\n" << questions[j] << "\n- "; getline(cin, participants[i].responses[j]); } } system(CLEAR_SCREEN); cout << "\nНажмите Enter, чтобы окончить тестирование..." << endl; cin.get(); system(CLEAR_SCREEN); cout << "\n\nВопросы:\n"; for (int i = 0; i < numQuestions; ++i) { cout << i + 1 << ". " << questions[i] << endl; } cout << "\n\nУчастники | Ответы:\n"; for (int i = 0; i < numParticipants; ++i) { cout << "\n\nИмя: " << participants[i].name << "\n" << endl; for (int j = 0; j < numQuestions; ++j) { cout << questions[j] << "\n -" << participants[i].responses[j] << endl; } } ofstream outFile("results.txt"); if (outFile.is_open()) { outFile << "Результаты тестирования:\n\n"; outFile << "Вопросы:\n"; for (int i = 0; i < numQuestions; ++i) { outFile << i + 1 << ". " << questions[i] << endl; } outFile << "\n\nИтоги:\n"; for (int i = 0; i < numParticipants; ++i) { outFile << "\n\n" << participants[i].name << endl; for (int j = 0; j < numQuestions; ++j) { outFile << j + 1 << ". " << participants[i].responses[j] << endl; } } outFile.close(); cout << "\n\nРезультаты были успешно сохранены в файле 'results.txt'." << endl; } else { cout << "Произошла ошибка при сохранении результатов." << endl; } return 0; } C #include <iostream> #include "windows.h" #include <fstream> #include <vector> #include <string> #ifdef _WIN32 #define CLEAR_SCREEN "cls" #else #define CLEAR_SCREEN "clear" #endif using namespace std; struct Answer { string name; vector<string> responses; }; int main() { setlocale(LC_ALL, ""); SetConsoleCP(1251); SetConsoleOutputCP(1251); int numQuestions, numParticipants; cout << "Введите количество задаваемых вопросов: "; cin >> numQuestions; cout << "\n"; cin.ignore(); vector<string> questions(numQuestions); for (int i = 0; i < numQuestions; ++i) { cout << "Введите вопрос #" << i + 1 << ": "; getline(cin, questions[i]); } cout << "\n" << "Введите количество участников опроса: "; cin >> numParticipants; cin.ignore(); vector<Answer> participants(numParticipants); for (int i = 0; i < numParticipants; ++i) { system(CLEAR_SCREEN); cout << "\nВведите ваше имя: "; getline(cin, participants[i].name); participants[i].responses.resize(numQuestions); for (int j = 0; j < numQuestions; ++j) { cout << "\n\n" << questions[j] << "\n- "; getline(cin, participants[i].responses[j]); } } system(CLEAR_SCREEN); cout << "\nНажмите Enter, чтобы окончить тестирование..." << endl; cin.get(); system(CLEAR_SCREEN); cout << "\n\nВопросы:\n"; for (int i = 0; i < numQuestions; ++i) { cout << i + 1 << ". " << questions[i] << endl; } cout << "\n\nУчастники | Ответы:\n"; for (int i = 0; i < numParticipants; ++i) { cout << "\n\nИмя: " << participants[i].name << "\n" << endl; for (int j = 0; j < numQuestions; ++j) { cout << questions[j] << "\n -" << participants[i].responses[j] << endl; } } ofstream outFile("results.txt"); if (outFile.is_open()) { outFile << "Результаты тестирования:\n\n"; outFile << "Вопросы:\n"; for (int i = 0; i < numQuestions; ++i) { outFile << i + 1 << ". " << questions[i] << endl; } outFile << "\n\nИтоги:\n"; for (int i = 0; i < numParticipants; ++i) { outFile << "\n\n" << participants[i].name << endl; for (int j = 0; j < numQuestions; ++j) { outFile << j + 1 << ". " << participants[i].responses[j] << endl; } } outFile.close(); cout << "\n\nРезультаты были успешно сохранены в файле 'results.txt'." << endl; } else { cout << "Произошла ошибка при сохранении результатов." << endl; } return 0; } еле как пофиксил отображение русского языка, как появилась другая проблема: перестали отображаться переменные с русскими символами. в этом примере, имена и вопросы. скрины что сохраняет софт и вот с англ:
dvbsh, друг, ты задаешь элементарный вопрос - люди за тебя гуглят и дают ответ. Не нравится ответ - не спрашивай на форуме
Cerberus, "элементарный вопрос", на который нигде (практически???) нет правильного ответа) C++ не адаптирован под подобную хуйню, и нужно извиваться во все стороны света, чтобы всё работало корректно. setlocale ваш нихуя не помогает, он фиксит ТОЛЬКО вывод. мне ТАКЖЕ нужно, чтобы данные на русском языке корректно сохранялись в переменные. я, конечно, был бы рад любой попытке мне помочь, но когда человек, имеющий мало чего общего с программированием, а особенно на плюсах, просто берёт первый ответ с гугла - это высокомерие и кринж