ПОмогите ПОжалуйста по C++
Створити базу даних військової техніки.
Реалізувати можливість
на 3:
Вводити та виводити дані на екран
на 4:
Додавати дані в список та виводити на екран
на 5:
додавати, видаляти та виводити дані на екран
Ответы
Ответ дал:
0
#include
#include
#include
using namespace std;
struct MilitaryVehicle {
string type;
int weight;
int maxSpeed;
};
vector militaryVehicles;
void addMilitaryVehicle() {
MilitaryVehicle vehicle;
cout
#include
#include
using namespace std;
struct MilitaryVehicle {
string type;
int weight;
int maxSpeed;
};
vector militaryVehicles;
void addMilitaryVehicle() {
MilitaryVehicle vehicle;
cout
Приложения:
Аноним:
бред какой-то, почему-то не все отправилось… напишите мне в тг, пожалуйста, я вам отправлю весь код @cvrnvu
или же давать в комментариях напишу
#include
#include
#include
using namespace std;
struct MilitaryVehicle {
string type;
int weight;
int maxSpeed;
};
vector militaryVehicles;
#include
#include
using namespace std;
struct MilitaryVehicle {
string type;
int weight;
int maxSpeed;
};
vector militaryVehicles;
militaryVehicles;
void addMilitaryVehicle() {
MilitaryVehicle vehicle;
cout << "Enter vehicle type: ";
cin >> vehicle.type;
cout << "Enter vehicle weight: ";
cin >> vehicle.weight;
cout << "Enter vehicle max speed: ";
void addMilitaryVehicle() {
MilitaryVehicle vehicle;
cout << "Enter vehicle type: ";
cin >> vehicle.type;
cout << "Enter vehicle weight: ";
cin >> vehicle.weight;
cout << "Enter vehicle max speed: ";
cin >> vehicle.maxSpeed;
militaryVehicles.push_back(vehicle);
cout << "Vehicle added successfully." << endl;
}
void removeMilitaryVehicle() {
int index;
cout << "Enter index of vehicle to remove: ";
cin >> index;
if (index < 0 || index >= militaryVehicles.size()) {
cout << "Invalid index." << endl;
} else {
militaryVehicles.push_back(vehicle);
cout << "Vehicle added successfully." << endl;
}
void removeMilitaryVehicle() {
int index;
cout << "Enter index of vehicle to remove: ";
cin >> index;
if (index < 0 || index >= militaryVehicles.size()) {
cout << "Invalid index." << endl;
} else {
militaryVehicles.erase(militaryVehicles.begin() + index);
cout << "Vehicle removed successfully." << endl;
}
}
void printMilitaryVehicles() {
if (militaryVehicles.empty()) {
cout << "No military vehicles in the database." << endl;
} else {
cout << "Military vehicles in the database:" << endl;
for (int i = 0; i < militaryVehicles.size(); i++) {
cout << "Vehicle " << i << ":" << endl;
cout << "Vehicle removed successfully." << endl;
}
}
void printMilitaryVehicles() {
if (militaryVehicles.empty()) {
cout << "No military vehicles in the database." << endl;
} else {
cout << "Military vehicles in the database:" << endl;
for (int i = 0; i < militaryVehicles.size(); i++) {
cout << "Vehicle " << i << ":" << endl;
cout << "Type: " << militaryVehicles[i].type << endl;
cout << "Weight: " << militaryVehicles[i].weight << endl;
cout << "Max speed: " << militaryVehicles[i].maxSpeed << endl;
cout << endl;
}
}
}
int main() {
int choice;
do {
cout << "Military Vehicle Database" << endl;
cout << "1. Add vehicle" << endl;
cout << "2. Remove vehicle" << endl;
cout << "3. Print vehicles" << endl;
cout << "Weight: " << militaryVehicles[i].weight << endl;
cout << "Max speed: " << militaryVehicles[i].maxSpeed << endl;
cout << endl;
}
}
}
int main() {
int choice;
do {
cout << "Military Vehicle Database" << endl;
cout << "1. Add vehicle" << endl;
cout << "2. Remove vehicle" << endl;
cout << "3. Print vehicles" << endl;
cout << "4. Quit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
addMilitaryVehicle();
break;
case 2:
removeMilitaryVehicle();
break;
case 3:
printMilitaryVehicles();
break;
case 4:
cout << "Goodbye!" << endl;
break;
default:
cout << "Invalid choice." << endl;
}
} while (choice != 4);
return 0;
}
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
addMilitaryVehicle();
break;
case 2:
removeMilitaryVehicle();
break;
case 3:
printMilitaryVehicles();
break;
case 4:
cout << "Goodbye!" << endl;
break;
default:
cout << "Invalid choice." << endl;
}
} while (choice != 4);
return 0;
}
задание на 5. Код рабочий, я его уже проверила. Будут вопросы-жду в тг. Если будет удобнее, могу весь скинуть в тг, просто скопируешь и вставишь в с++
в комментариях код не совсем правильно отправился почему-то.Некоторые коды приложение не пропустило. Еще раз прошу прощения за такую ошибку, если вам нужна будет помощь, напишите в телеграмм в любое время, скину код.
Вас заинтересует
1 год назад
1 год назад
1 год назад
3 года назад
8 лет назад