Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <deque>
- #include <string>
- using namespace std;
- class bus_park {
- struct bus_info {
- string num_bus,
- num_route,
- fio;
- };
- deque<bus_info> list_in_park;
- deque<bus_info> list_in_route;
- bus_info bi;
- public:
- // ======интерфейс======
- void input();
- void print(int where);
- void departure_park();
- void entry_park();
- //======================
- };
- void bus_park::input() {
- cin.ignore();
- cout << "введите номер автобуса" << endl;
- getline(cin, bi.num_bus);
- cout << "введите номер маршрута" << endl;
- getline(cin, bi.num_route);
- cout << "введите ФИО водителя" << endl;
- getline(cin, bi.fio);
- list_in_park.push_back(bi);
- }
- void bus_park::print(int where) {
- cout << "номер автобуса номер маршрута ФИО водителя" << endl;
- if (where == 0) {
- for (int i = 0; i < list_in_park.size(); i++) {
- cout << list_in_park[i].num_bus << setw((__int64)17 - list_in_park[i].num_bus.length() + list_in_park[i].num_route.length());
- cout << list_in_park[i].num_route << setw((__int64)17 - list_in_park[i].num_route.length() + list_in_park[i].fio.length());
- cout << list_in_park[i].fio;
- cout << endl;
- }
- } else {
- for (int i = 0; i < list_in_route.size(); i++) {
- cout << list_in_route[i].num_bus << setw((__int64)17 - list_in_route[i].num_bus.length() + list_in_route[i].num_route.length());
- cout << list_in_route[i].num_route << setw((__int64)17 - list_in_route[i].num_route.length() + list_in_route[i].fio.length());
- cout << list_in_route[i].fio;
- cout << endl;
- }
- }
- }
- void bus_park::departure_park() {
- string route_number;
- cout << "Введите номер автобуса" << endl;
- cin >> route_number;
- for (int i = 0; i < list_in_park.size(); i++) {
- if (list_in_park[i].num_bus == route_number) {
- list_in_route.push_back( list_in_park[i] );
- list_in_park.erase( list_in_park.begin() + i );
- }
- }
- }
- void bus_park::entry_park() {
- string route_number;
- cout << "Введите номер автобуса" << endl;
- cin >> route_number;
- for (int i = 0; i < list_in_route.size(); i++) {
- if (list_in_route[i].num_bus == route_number) {
- list_in_park.push_back(list_in_route[i]);
- list_in_route.erase(list_in_route.begin() + i);
- }
- }
- }
- int main() {
- bus_park BP;
- int item;
- do {
- system("CLS");
- cout << "1 - Ввод данных" << endl;
- cout << "2 - Вывод автобусов в парке" << endl;
- cout << "3 - Вывод автобусов на маршруте" << endl;
- cout << "4 - Имитация выезда автобуса из парка" << endl;
- cout << "5 - Имитация въезда автобуса в парк" << endl;
- cout << "6 - Выход" << endl;
- cout << "============================" << endl;
- cout << "Введите номер пункта меню" << endl;
- cin >> item;
- switch (item) {
- case 1:
- BP.input();
- break;
- case 2:
- BP.print(0);
- system("pause");
- break;
- case 3:
- BP.print(1);
- system("pause");
- break;
- case 4:
- BP.print(0);
- cout << "====================================\n\n";
- BP.departure_park();
- system("pause");
- break;
- case 5:
- BP.print(1);
- cout << "====================================\n\n";
- BP.entry_park();
- system("pause");
- break;
- case 6: return 0;
- default:
- cout << "Неверно введён номер!" << endl;
- cin.get();
- break;
- }
- } while (1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement