Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #define SIZE 4
- using namespace std;
- struct Plane {
- char company[30];
- char surname[30];
- char name[30];
- int flight;
- int price;
- Plane() {}
- Plane(char company[30], char surname[30], char name[30], int flight, int price)
- {
- memcpy(this->name, name, sizeof(name));
- memcpy(this->surname, surname, sizeof(surname));
- memcpy(this->company, company, sizeof(company));
- this->flight = flight;
- this->price = price;
- }
- };
- void add(Plane* planes)
- {
- for (int i = 0; i < SIZE; i++)
- {
- char name[30];
- char surname[30];
- char company[30];
- int flight;
- int price;
- cout << "Enter company, name, surname, flight and price of ticket" << endl;
- cin >> name >> surname >> company >> flight >> price;
- memcpy(planes[i].name, name, sizeof(name));
- memcpy(planes[i].surname, surname, sizeof(surname));
- memcpy(planes[i].company, company, sizeof(company));
- planes[i].flight = flight;
- planes[i].price = price;
- }
- }
- void show(Plane* pl)
- {
- for (int i = 0; i < SIZE; i++)
- {
- cout << "Company: " << pl[i].company << endl;
- cout << "Name: " << pl[i].name << " Surname: " << pl[i].surname << endl;
- cout << "Flight: " << pl[i].flight << endl;
- cout << "Price: " << pl[i].price << endl;
- }
- }
- void findFlight(Plane* p, const char comp[30])
- {
- for (int i = 0; i < SIZE; i++)
- {
- if (p[i].company == comp)
- {
- cout << "Flight: " << p->flight << endl;
- }
- }
- }
- void findPassengers(Plane* p, int flight)
- {
- vector<char[30]> passengers;
- for (int i = 0; i < SIZE; i++)
- {
- if (p[i].flight == flight)
- {
- passengers.push_back(p[i].surname);
- }
- }
- sort(passengers.begin(), passengers.end());
- for (auto x : passengers)
- cout << x << endl;
- }
- int main()
- {
- Plane* planes = new Plane[SIZE];
- add(planes);
- findFlight(planes, "jmix");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement