Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

У меня в консоль выводятся краказябры. Исправь #include <iostream> #include <string>…

  1. User

    У меня в консоль выводятся краказябры. Исправь

    #include #include #include <windows.h> #include "stdio.h" #include

    using namespace std;

    struct Rule { string condition; // Условная часть правила string action; // Исполняемая часть правила bool isActive = true; // Флаг использования правила };

    const char delimiter = ','; // Разделитель для условий "И" Rule rules[100]; // Массив для хранения правил string workMemory[100]; // Рабочая память int factCount = 0; // Количество фактов в памяти int ruleCount = 0; // Количество правил

    string trim(string s) // Удаление пробелов с начала и конца строки { while (!s.empty() && s[0] == ' ') s.erase(0, 1); while (!s.empty() && s.back() == ' ') s.pop_back(); return s; }

    string extractFact(string& s) // Извлечение факта из строки { string fact; int pos = s.find(delimiter); if (pos < 0) { fact = s; s.clear(); } else { fact = s.substr(0, pos); s.erase(0, pos + 1); } return fact; }

    bool isFactPresent(const string& s) // Проверка наличия факта в рабочей памяти { string fact = trim(s); for (int i = 0; i < factCount; i++) if (workMemory[i] == fact) return true; return false; }

    void addFact(string fact) // Добавление нового факта в память { fact = trim(fact); if (!isFactPresent(fact)) workMemory[factCount++] = fact; }

    void showFacts() // Вывод фактов, хранящихся в рабочей памяти { cout << "\nСостояние рабочей памяти:\n"; if (factCount == 0) cout << "Рабочая память пуста\n"; else { for (int i = 0; i < factCount; i++) cout << i + 1 << ". " << workMemory[i] << endl; } cout << endl; }

    void initializeRules() { // Инициализация правил по условиям задачи rules[0] = { "Алеша провожает друга на автобус", "Алеша не на автобусе" }; rules[1] = { "Мимо них проходит троллейбус", "Алеша не на троллейбусе" }; rules[2] = { "Алеша не на автобусе, Алеша не на троллейбусе", "Алеша на трамвае" }; rules[3] = { "Третий друг крикнул из троллейбуса: Боря, ты забыл тетрадь!", "Боря не на троллейбусе" }; rules[4] = { "Боря не на троллейбусе, Алеша не на троллейбусе", "Витя на троллейбусе" }; rules[5] = { "Алеша на трамвае, Витя на троллейбусе", "Боря на автобусе" }; ruleCount = 6; }

    void showRules() // Вывод всех правил { cout << "\nПравила: \n"; for (int i = 0; i < ruleCount; i++) { cout << i + 1 << ". ЕСЛИ " << rules[i].condition << " ТО " << rules[i].action << endl; } cout << endl; }

    bool evaluateCondition(string s) // Проверка истинности условия { while (!s.empty()) { if (!isFactPresent(extractFact(s))) return false; } return true; }

    bool applyRule(int index) // Применение правила по индексу { if (rules[index].isActive && evaluateCondition(rules[index].condition)) { addFact(rules[index].action); rules[index].isActive = false; return true; } return false; }

    void performInference() // Механизм прямого логического вывода { initializeRules(); // Изначальные факты addFact("Алеша провожает друга на автобус"); addFact("Мимо них проходит троллейбус"); addFact("Третий друг крикнул из троллейбуса: Боря, ты забыл тетрадь!"); // Прямой вывод bool isUpdated; do { isUpdated = false; for (int i = 0; i < ruleCount; i++) if (applyRule(i)) isUpdated = true;

    } while (isUpdated);
    showFacts();
    // Итоговое решение
    string alesha, borya, vitya;
    for (int i = 0; i < factCount; i++)
    {
    	if (workMemory[i].find("Алеша") != string::npos)
    		alesha = workMemory[i];
    	else if (workMemory[i].find("Боря") != string::npos)
    		borya = workMemory[i];
    	else if (workMemory[i].find("Витя") != string::npos)
    		vitya = workMemory[i];
    }
    cout << "\nОкончательное решение:\n";
    cout << "Алеша: " << alesha.substr(alesha.find(" ") + 1) << endl;
    cout << "Боря: " << borya.substr(borya.find(" ") + 1) << endl;
    cout << "Витя: " << vitya.substr(vitya.find(" ") + 1) << endl;
    

    }

    char showMenu() // Показ меню { char choice; cout << "\n Меню:\n"; cout << "1. Прямой поиск решений\n"; cout << "2. Выход\n"; cout << "Выберите пункт меню: "; cin >> choice; return choice; }

    int main(int argc, char* argv) { SetConsoleCP(1251); SetConsoleOutputCP(1251); setlocale(LC_CTYPE, "rus"); cout << "Решение логической задачи о профессиях и фамилиях\n"; char choice; do { choice = showMenu(); if (choice == '1') performInference(); } while (choice != '2'); system("pause"); return 0; }

  2. Assistant

    У вас могут возникать проблемы с отображением кириллических символов в консоли, что приводит к "краказябрам". Это часто происходит из-за неправильной настройки кодировки. Вы уже установили кодировку консоли на 1251 с помощью функций SetConsoleCP и SetConsoleOutputCP, а также вызвали setlocale для русской локали. Однако, бывают случаи, когда этого недостаточно.

    Вот несколько рекомендаций, чтобы убедиться, что ваше приложение корректно отображает кириллические символы:

    1. Убедитесь, что ваш код сохранен в правильной кодировке:

      • Если вы используете IDE вроде Visual Studio, убедитесь, что файл источника сохранен в формате с поддержкой UTF-8 или Windows-1251.
    2. Изменение кодировки в консоли:

      • Убедитесь, что консоль Windows также настроена на использование кодировки Windows-1251. Это можно сделать вручную, воспользовавшись командой chcp 1251 в консоли перед запуском приложения.
    3. Проверьте вызовы функций установки кодировки:

      • Перепроверьте функции SetConsoleCP и SetConsoleOutputCP, чтобы убедиться, что они вызываются правильно.
    4. Проверка на других системах:

      • Попробуйте запустить вашу программу на другой машине или в другой среде, чтобы понять, локальная это проблема или нет.
    5. Замена system("pause"):

      • Вместо system("pause") попробуйте использовать более переносимый способ, например:
        cout << "Нажмите любую клавишу для выхода..." << endl;
        cin.ignore();
        cin.get();
        

    Если все эти шаги не помогают, вы можете попробовать начать с простого примера вывода кириллического текста и постепенно усложнять код, чтобы найти источник проблемы.

    Если у вас есть доступ к более современным системам, возможно, стоит рассмотреть альтернативу, например, использование wcout для работы с широкими символами и установку локали:

    #include <locale>
    #include <io.h>
    #include <fcntl.h>
    
    // В начале функции main()
    _setmode(_fileno(stdout), _O_U16TEXT);
    std::wcout.imbue(std::locale("ru_RU.UTF-8"));
    

    Это не всегда необходимо, но может помочь в случаях, когда ничего другое не работает.

  3. User

    переведи все русские фразы на английский #include #include #include <windows.h> #include "stdio.h" #include //#include //#include <io.h> //#include <fcntl.h>

    using namespace std;

    struct Rule { string condition; // Условная часть правила string action; // Исполняемая часть правила bool isActive = true; // Флаг использования правила };

    const char delimiter = ','; // Разделитель для условий "И" Rule rules[100]; // Массив для хранения правил string workMemory[100]; // Рабочая память int factCount = 0; // Количество фактов в памяти int ruleCount = 0; // Количество правил

    string trim(string s) // Удаление пробелов с начала и конца строки { while (!s.empty() && s[0] == ' ') s.erase(0, 1); while (!s.empty() && s.back() == ' ') s.pop_back(); return s; }

    string extractFact(string& s) // Извлечение факта из строки { string fact; int pos = s.find(delimiter); if (pos < 0) { fact = s; s.clear(); } else { fact = s.substr(0, pos); s.erase(0, pos + 1); } return fact; }

    bool isFactPresent(const string& s) // Проверка наличия факта в рабочей памяти { string fact = trim(s); for (int i = 0; i < factCount; i++) if (workMemory[i] == fact) return true; return false; }

    void addFact(string fact) // Добавление нового факта в память { fact = trim(fact); if (!isFactPresent(fact)) workMemory[factCount++] = fact; }

    void showFacts() // Вывод фактов, хранящихся в рабочей памяти { cout << "\nСостояние рабочей памяти:\n"; if (factCount == 0) cout << "Рабочая память пуста\n"; else { for (int i = 0; i < factCount; i++) cout << i + 1 << ". " << workMemory[i] << endl; } cout << endl; }

    void initializeRules() { // Инициализация правил по условиям задачи rules[0] = { "Алеша провожает друга на автобус", "Алеша не на автобусе" }; rules[1] = { "Мимо них проходит троллейбус", "Алеша не на троллейбусе" }; rules[2] = { "Алеша не на автобусе, Алеша не на троллейбусе", "Алеша на трамвае" }; rules[3] = { "Третий друг крикнул из троллейбуса: Боря, ты забыл тетрадь!", "Боря не на троллейбусе" }; rules[4] = { "Боря не на троллейбусе, Алеша не на троллейбусе", "Витя на троллейбусе" }; rules[5] = { "Алеша на трамвае, Витя на троллейбусе", "Боря на автобусе" }; ruleCount = 6; }

    void showRules() // Вывод всех правил { cout << "\nПравила: \n"; for (int i = 0; i < ruleCount; i++) { cout << i + 1 << ". ЕСЛИ " << rules[i].condition << " ТО " << rules[i].action << endl; } cout << endl; }

    bool evaluateCondition(string s) // Проверка истинности условия { while (!s.empty()) { if (!isFactPresent(extractFact(s))) return false; } return true; }

    bool applyRule(int index) // Применение правила по индексу { if (rules[index].isActive && evaluateCondition(rules[index].condition)) { addFact(rules[index].action); rules[index].isActive = false; return true; } return false; }

    void performInference() // Механизм прямого логического вывода { initializeRules(); // Изначальные факты addFact("Алеша провожает друга на автобус"); addFact("Мимо них проходит троллейбус"); addFact("Третий друг крикнул из троллейбуса: Боря, ты забыл тетрадь!"); // Прямой вывод bool isUpdated; do { isUpdated = false; for (int i = 0; i < ruleCount; i++) if (applyRule(i)) isUpdated = true;

    } while (isUpdated);
    showFacts();
    // Итоговое решение
    string alesha, borya, vitya;
    for (int i = 0; i < factCount; i++)
    {
    	if (workMemory[i].find("Алеша") != string::npos)
    		alesha = workMemory[i];
    	else if (workMemory[i].find("Боря") != string::npos)
    		borya = workMemory[i];
    	else if (workMemory[i].find("Витя") != string::npos)
    		vitya = workMemory[i];
    }
    cout << "\nОкончательное решение:\n";
    cout << "Алеша: " << alesha.substr(alesha.find(" ") + 1) << endl;
    cout << "Боря: " << borya.substr(borya.find(" ") + 1) << endl;
    cout << "Витя: " << vitya.substr(vitya.find(" ") + 1) << endl;
    

    }

    char showMenu() // Показ меню { char choice; cout << "\n Меню:\n"; cout << "1. Прямой поиск решений\n"; cout << "2. Выход\n"; cout << "Выберите пункт меню: "; cin >> choice; return choice; }

    int main(int argc, char* argv) { // В начале функции main() //_setmode(_fileno(stdout), _O_U16TEXT); //std::wcout.imbue(std::locale("ru_RU.UTF-8"));

    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);
    setlocale(LC_CTYPE, "rus");
    cout << "Решение логической задачи о профессиях и фамилиях\n";
    char choice;
    do
    {
    	choice = showMenu();
    	if (choice == '1')
    		performInference();
    } while (choice != '2');
    system("pause");
    return 0;
    

    }

  4. Assistant

    Вот модифицированная версия вашего кода с переводом всех русских фраз и комментариев на английский:

    #include <iostream>
    #include <string>
    #include <windows.h>
    #include "stdio.h"
    #include <clocale>
    //#include <locale>
    //#include <io.h>
    //#include <fcntl.h>
    
    using namespace std;
    
    struct Rule
    {
        string condition; // Condition part of the rule
        string action;    // Action part of the rule
        bool isActive = true; // Flag for rule usage
    };
    
    const char delimiter = ','; // Delimiter for "AND" conditions
    Rule rules[100];  // Array to store rules
    string workMemory[100]; // Working memory
    int factCount = 0; // Count of facts in memory
    int ruleCount = 0; // Count of rules
    
    string trim(string s) // Remove spaces from the beginning and end of a string
    {
        while (!s.empty() && s[0] == ' ')
            s.erase(0, 1);
        while (!s.empty() && s.back() == ' ')
            s.pop_back();
        return s;
    }
    
    string extractFact(string& s) // Extract a fact from a string
    {
        string fact;
        int pos = s.find(delimiter);
        if (pos < 0)
        {
            fact = s;
            s.clear();
        }
        else
        {
            fact = s.substr(0, pos);
            s.erase(0, pos + 1);
        }
        return fact;
    }
    
    bool isFactPresent(const string& s) // Check if a fact is present in working memory
    {
        string fact = trim(s);
        for (int i = 0; i < factCount; i++)
            if (workMemory[i] == fact)
                return true;
        return false;
    }
    
    void addFact(string fact) // Add a new fact to memory
    {
        fact = trim(fact);
        if (!isFactPresent(fact))
            workMemory[factCount++] = fact;
    }
    
    void showFacts() // Display facts stored in working memory
    {
        cout << "\nState of working memory:\n";
        if (factCount == 0)
            cout << "Working memory is empty\n";
        else
        {
            for (int i = 0; i < factCount; i++)
                cout << i + 1 << ". " << workMemory[i] << endl;
        }
        cout << endl;
    }
    
    void initializeRules()
    {
        // Initialize rules according to task conditions
        rules[0] = { "Alesha sees his friend off to the bus", "Alesha is not on the bus" };
        rules[1] = { "A trolleybus passes by them", "Alesha is not on the trolleybus" };
        rules[2] = { "Alesha is not on the bus, Alesha is not on the trolleybus", "Alesha is on the tram" };
        rules[3] = { "The third friend shouted from the trolleybus: Borya, you forgot your notebook!", "Borya is not on the trolleybus" };
        rules[4] = { "Borya is not on the trolleybus, Alesha is not on the trolleybus", "Vitya is on the trolleybus" };
        rules[5] = { "Alesha is on the tram, Vitya is on the trolleybus", "Borya is on the bus" };
        ruleCount = 6;
    }
    
    void showRules() // Display all rules
    {
        cout << "\nRules: \n";
        for (int i = 0; i < ruleCount; i++)
        {
            cout << i + 1 << ". IF " << rules[i].condition
                << " THEN " << rules[i].action << endl;
        }
        cout << endl;
    }
    
    bool evaluateCondition(string s) // Check the truth of a condition
    {
        while (!s.empty())
        {
            if (!isFactPresent(extractFact(s)))
                return false;
        }
        return true;
    }
    
    bool applyRule(int index) // Apply a rule by its index
    {
        if (rules[index].isActive && evaluateCondition(rules[index].condition))
        {
            addFact(rules[index].action);
            rules[index].isActive = false;
            return true;
        }
        return false;
    }
    
    void performInference() // Forward reasoning mechanism
    {
        initializeRules();
        // Initial facts
        addFact("Alesha sees his friend off to the bus");
        addFact("A trolleybus passes by them");
        addFact("The third friend shouted from the trolleybus: Borya, you forgot your notebook!");
        // Forward chain reasoning
        bool isUpdated;
        do
        {
            isUpdated = false;
            for (int i = 0; i < ruleCount; i++)
                if (applyRule(i))
                    isUpdated = true;
        } while (isUpdated);
        
        showFacts();
        
        // Final solution
        string alesha, borya, vitya;
        for (int i = 0; i < factCount; i++)
        {
            if (workMemory[i].find("Alesha") != string::npos)
                alesha = workMemory[i];
            else if (workMemory[i].find("Borya") != string::npos)
                borya = workMemory[i];
            else if (workMemory[i].find("Vitya") != string::npos)
                vitya = workMemory[i];
        }
        
        cout << "\nFinal result:\n";
        cout << "Alesha: " << alesha.substr(alesha.find(" ") + 1) << endl;
        cout << "Borya: " << borya.substr(borya.find(" ") + 1) << endl;
        cout << "Vitya: " << vitya.substr(vitya.find(" ") + 1) << endl;
    }
    
    char showMenu() // Display menu
    {
        char choice;
        cout << "\n Menu:\n";
        cout << "1. Forward reasoning search\n";
        cout << "2. Exit\n";
        cout << "Choose menu item: ";
        cin >> choice;
        return choice;
    }
    
    int main(int argc, char* argv)
    {
        // At the start of the main function
        //_setmode(_fileno(stdout), _O_U16TEXT);
        //std::wcout.imbue(std::locale("ru_RU.UTF-8"));
    
        SetConsoleCP(1251);
        SetConsoleOutputCP(1251);
        setlocale(LC_CTYPE, "rus");
        cout << "Solution to the logical problem about professions and surnames\n";
        char choice;
        do
        {
            choice = showMenu();
            if (choice == '1')
                performInference();
        } while (choice != '2');
        system("pause");
        return 0;
    }
    

    Я перевел все строки и комментарии в коде на английский язык. Если потребуется дальнейшая помощь, дайте знать!

  5. User

    #include #include #include <windows.h> #include "stdio.h" #include //#include //#include <io.h> //#include <fcntl.h>

    using namespace std;

    struct Rule { string condition; // Condition part of the rule string action; // Action part of the rule bool isActive = true; // Flag for rule usage };

    const char delimiter = ','; // Delimiter for "AND" conditions Rule rules[100]; // Array to store rules string workMemory[100]; // Working memory int factCount = 0; // Count of facts in memory int ruleCount = 0; // Count of rules

    string trim(string s) // Remove spaces from the beginning and end of a string { while (!s.empty() && s[0] == ' ') s.erase(0, 1); while (!s.empty() && s.back() == ' ') s.pop_back(); return s; }

    string extractFact(string& s) // Extract a fact from a string { string fact; int pos = s.find(delimiter); if (pos < 0) { fact = s; s.clear(); } else { fact = s.substr(0, pos); s.erase(0, pos + 1); } return fact; }

    bool isFactPresent(const string& s) // Check if a fact is present in working memory { string fact = trim(s); for (int i = 0; i < factCount; i++) if (workMemory[i] == fact) return true; return false; }

    void addFact(string fact) // Add a new fact to memory { fact = trim(fact); if (!isFactPresent(fact)) workMemory[factCount++] = fact; }

    void showFacts() // Display facts stored in working memory { cout << "\nState of working memory:\n"; if (factCount == 0) cout << "Working memory is empty\n"; else { for (int i = 0; i < factCount; i++) cout << i + 1 << ". " << workMemory[i] << endl; } cout << endl; }

    void initializeRules() { // Initialize rules according to task conditions rules[0] = { "Alesha sees his friend off to the bus", "Alesha is not on the bus" }; rules[1] = { "A trolleybus passes by them", "Alesha is not on the trolleybus" }; rules[2] = { "Alesha is not on the bus, Alesha is not on the trolleybus", "Alesha is on the tram" }; rules[3] = { "The third friend shouted from the trolleybus: Borya, you forgot your notebook!", "Borya is not on the trolleybus" }; rules[4] = { "Borya is not on the trolleybus, Alesha is not on the trolleybus", "Vitya is on the trolleybus" }; rules[5] = { "Alesha is on the tram, Vitya is on the trolleybus", "Borya is on the bus" }; ruleCount = 6; }

    void showRules() // Display all rules { cout << "\nRules: \n"; for (int i = 0; i < ruleCount; i++) { cout << i + 1 << ". IF " << rules[i].condition << " THEN " << rules[i].action << endl; } cout << endl; }

    bool evaluateCondition(string s) // Check the truth of a condition { while (!s.empty()) { if (!isFactPresent(extractFact(s))) return false; } return true; }

    bool applyRule(int index) // Apply a rule by its index { if (rules[index].isActive && evaluateCondition(rules[index].condition)) { addFact(rules[index].action); rules[index].isActive = false; return true; } return false; }

    void performInference() // Forward reasoning mechanism { initializeRules(); // Initial facts addFact("Alesha sees his friend off to the bus"); addFact("A trolleybus passes by them"); addFact("The third friend shouted from the trolleybus: Borya, you forgot your notebook!"); // Forward chain reasoning bool isUpdated; do { isUpdated = false; for (int i = 0; i < ruleCount; i++) if (applyRule(i)) isUpdated = true; } while (isUpdated);

    showFacts();
    
    // Final solution
    string alesha, borya, vitya;
    for (int i = 0; i < factCount; i++)
    {
    	if (workMemory[i].find("Alesha") != string::npos)
    		alesha = workMemory[i];
    	else if (workMemory[i].find("Borya") != string::npos)
    		borya = workMemory[i];
    	else if (workMemory[i].find("Vitya") != string::npos)
    		vitya = workMemory[i];
    }
    
    cout << "\nFinal result:\n";
    cout << "Alesha: " << alesha.substr(alesha.find(" ") + 1) << endl;
    cout << "Borya: " << borya.substr(borya.find(" ") + 1) << endl;
    cout << "Vitya: " << vitya.substr(vitya.find(" ") + 1) << endl;
    

    }

    char showMenu() // Display menu { char choice; cout << "\n Menu:\n"; cout << "1. Forward reasoning search\n"; cout << "2. Exit\n"; cout << "Choose menu item: "; cin >> choice; return choice; }

    int main(int argc, char* argv) { // At the start of the main function //_setmode(_fileno(stdout), _O_U16TEXT); //std::wcout.imbue(std::locale("ru_RU.UTF-8"));

    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);
    setlocale(LC_CTYPE, "rus");
    cout << "Solution to the logical problem about professions and surnames\n";
    char choice;
    do
    {
    	choice = showMenu();
    	if (choice == '1')
    		performInference();
    } while (choice != '2');
    system("pause");
    return 0;
    

    } Solution to the logical problem about professions and surnames

    Search Vinal St

    Menu:

    1. Forward reasoning search

    2. Exit

    Choose menu iten: 1

    argc,

    State of working memory:

    1. Alesha sees his friend off to the bus 2. A trolleybus passes by then

    2. The third friend shouted from the trolleybus: Borya, you forgot your notebook

    3. Alesha is not on the bus

    4. Alesha is not on the trolleybus

    5. Alesha is on the tran

    Alesha: is on the tran

    Final result:

    Borya: third friend shouted from the trolleybus: Borya, you forgot your notebook

    Uitya:

    Menu:

    1. Forward reasoning search

    2. Exit

    Choose menu iten: A

  6. Assistant

    It seems there might be a few issues in your code involving input/output processing or logic execution. Let's address these step by step:

    1. Output Formatting Issues: Your console output has some misprints, like "Search Vinal St", "iten" instead of "item", and "on the tran".

      a. Ensure Correct Spelling: Double-check the text literals used in your code for any spelling errors:

      • "Solution to the logical problem about professions and surnames" instead of "Search Vinal St".
      • "Choose menu item:" instead of "Choose menu iten:".
      • "tram" instead of "tran".
    2. Use Proper Memory Handling:

      Ensure that the find method's results are used properly to extract substrings. When you look for the word after a name and 'is' in sentences, make sure you have all necessary elements correctly aligned.

      For instance, check that the substring extraction indexes are correct.

    3. Fix Logic in performInference():

      Based on the output you described, it appears there is an issue with how final results are derived for Borya and Vitya. Ensure conditions are set and evaluated properly.

    Here's a refined function that could help correct the final output logic in performInference():

    void performInference() // Forward reasoning mechanism
    {
        initializeRules();
        // Initial facts
        addFact("Alesha sees his friend off to the bus");
        addFact("A trolleybus passes by them");
        addFact("The third friend shouted from the trolleybus: Borya, you forgot your notebook!");
        // Forward chain reasoning
        bool isUpdated;
        do
        {
            isUpdated = false;
            for (int i = 0; i < ruleCount; i++)
                if (applyRule(i))
                    isUpdated = true;
        } while (isUpdated);
    
        showFacts();
    
        // Final solutions
        string alesha, borya, vitya;
        for (int i = 0; i < factCount; i++)
        {
            if (workMemory[i].find("Alesha") == 0)
                alesha = workMemory[i];
            else if (workMemory[i].find("Borya") == 0)
                borya = workMemory[i];
            else if (workMemory[i].find("Vitya") == 0)
                vitya = workMemory[i];
        }
    
        cout << "\nFinal result:\n";
        cout << "Alesha: " << (alesha.empty() ? "Unknown" : alesha.substr(alesha.find(" ") + 1)) << endl;
        cout << "Borya: " << (borya.empty() ? "Unknown" : borya.substr(borya.find(" ") + 1)) << endl;
        cout << "Vitya: " << (vitya.empty() ? "Unknown" : vitya.substr(vitya.find(" ") + 1)) << endl;
    }
    
    • Error Checking: Defaults to "Unknown" if the string isn't found correctly, preventing incorrect or empty outputs.
    1. Language Settings: Make sure language settings and locale setup reflect correctly in the console for any potential language/locale issues, ideally using UTF-8.

    Retesting your program with these adjustments should help in reflecting the correct logical states and output formatting. If the system language configuration or environment might be causing obscure behavior, verify they align appropriately for your intended language.