Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

Исправь ошибку с gets. int main() { const int MAXSIZE = 100; Car cars[MAXSIZE]; int n =…

  1. User

    Исправь ошибку с gets. int main() { const int MAX_SIZE = 100; Car cars[MAX_SIZE]; int n = 0; load_data(cars, n); int choice; do { cout << "Menu" << endl << "1. Add a new car" << endl << "2. Print the information about a car" << endl << "3. Search for cars that need maintenance" << endl << "4. Search for cars of a given brand" << endl << "5. Search for owners with mileage greater than a specified one" << endl << "6. Exit" << endl << "Enter your choice: "<< endl; gets(choice)

  2. Assistant

    Исправленный вариант:

    #include #include using namespace std;

    const int MAX_SIZE = 100;

    struct Car { string brand; string model; int mileage; string owner; };

    void load_data(Car cars[], int& n) { //загрузка данных о машинах из файла или другого источника в массив cars, изменение n }

    int main() { Car cars[MAX_SIZE]; int n = 0; load_data(cars, n); int choice; do { cout << "Menu" << endl << "1. Add a new car" << endl << "2. Print the information about a car" << endl << "3. Search for cars that need maintenance" << endl << "4. Search for cars of a given brand" << endl << "5. Search for owners with mileage greater than a specified one" << endl << "6. Exit" << endl << "Enter your choice: "; cin >> choice; cin.ignore(); //для очистки буфера ввода от \n после cin } while (choice != 6); return 0; }