Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- #include <list>
- #include <cstring>
- using namespace std;
- #define CHAR_LEN 255
- typedef struct show
- {
- int id;
- char name[CHAR_LEN],
- date[CHAR_LEN];
- } show_t;
- list<show_t> shows;
- typedef struct guest
- {
- char name[CHAR_LEN];
- list<show_t> tickets;
- } guest_t;
- int main()
- {
- system("chcp 1251");
- guest_t tempGuest;
- list<guest_t> guests;
- show_t tempShow;
- int temp;
- cout << "Какое количество представлений вы хотите добавить: ";
- cin >> temp;
- for (int i = 0; i < temp; i++)
- {
- cout << "ID: ";
- cin >> tempShow.id;
- cout << "Название представления: ";
- cin >> tempShow.name;
- cout << "Дата проведения: ";
- cin >> tempShow.date;
- shows.push_back(tempShow);
- }
- cout << "\nСПИСОК ПРЕДСТАВЛЕНИЙ" << endl;
- for (list<show_t>::iterator it = shows.begin(); it != shows.end(); ++it)
- cout << it->id << '\t' << it->name << '\t' << it->date << endl;
- cout << "----------" << endl;
- cout << "Какое количество зрителей вы хотите добавить в систему: ";
- cin >> temp;
- for (int i = 0; i < temp; i++)
- {
- cout << "Имя зрителя: ";
- cin >> tempGuest.name;
- cout << "Список представлений: " << endl;
- for (list<show_t>::iterator it = shows.begin(); it != shows.end(); ++it)
- cout << '\t' << it->id << '\t' << it->name << '\t' << it->date << endl;
- cout << "----------" << endl;
- cout << "На какие представления вы хотите сходить(ID)(-1 = конец ввода): " << endl;
- int ticketNum;
- while (cin >> ticketNum)
- {
- if (ticketNum == -1)
- break;
- for (list<show_t>::iterator it = shows.begin(); it != shows.end(); ++it)
- {
- if (it->id == ticketNum)
- {
- tempGuest.tickets.push_back(*it);
- break;
- }
- }
- }
- guests.push_back(tempGuest);
- tempGuest.tickets.clear();
- }
- cout << "\nСПИСОК ЗРИТЕЛЕЙ" << endl;
- for (list<guest_t>::iterator it = guests.begin(); it != guests.end(); it++)
- {
- cout << "Имя зрителя: " << it->name << endl;
- cout << "Список зарезервированных билетов: " << endl;
- for (list<show_t>::iterator t_it = it->tickets.begin(); t_it != it->tickets.end(); t_it++)
- cout << t_it->id << '\t' << t_it->name << '\t' << t_it->date << endl;
- cout << "----------" << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement