Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Train
- {
- int number;
- string dep;
- string dist;
- int time_depch;
- int time_depmin;
- int time_ch;
- int time_min;
- int ticket;
- };
- void display(Train);
- void display2(Train*);
- int main()
- {
- setlocale(LC_ALL, "Rus");
- Train box1 = { 201, "Москва", "Санкт-Петербург", 8 , 18, 3, 30, 3500 },
- box2{ 204, "Москва", "Санкт-Петербург", 12, 44, 4, 15, 3800 },
- box3{ 225, "Москва", "Сочи\t", 9, 20, 22, 38, 7500 },
- box4{ 355, "Москва", "Санкт-Петербург", 7, 44, 4, 15, 2800 },
- box5{ 725, "Москва", "Сочи\t", 12, 25, 21, 47, 9500 },
- box6{ 925, "Москва", "Адлер\t", 14, 25, 23, 47, 2500 },
- box7{ 655, "Москва", "Махачкала", 12, 25, 40, 47, 4500 },
- box8{ 204, "Москва", "Санкт-Петербург", 8, 40, 3, 15, 4200 };
- cout << "Номер поезда.\tПункт отправления.\tПункт назанчения.\tВремя отправления.\tВремя в пути.\tЦена билета.";
- cout << endl;
- display(box1);
- display(box2);
- display(box3);
- display(box4);
- display(box5);
- display(box6);
- display(box7);
- display(box8);
- cout << "\nМосква -> Санкт-Петербург время отправления от 7:00 до 9:00.\n" << endl;
- cout << "Номер поезда.\tПункт отправления.\tПункт назанчения.\tВремя отправления.\tВремя в пути.\tЦена билета.";
- cout << endl;
- display2(&box1);
- display2(&box2);
- display2(&box3);
- display2(&box4);
- display2(&box5);
- display2(&box6);
- display2(&box7);
- display2(&box8);
- return 0;
- }
- void display(Train box)
- {
- cout << box.number << "\t\t" << box.dep << "\t\t\t" << box.dist
- << "\t\t" << box.time_depch << ":" << box.time_depmin
- << "\t\t\t" << box.time_ch << ":" << box.time_min << "\t\t"
- << box.ticket;
- cout << endl;
- };
- void display2(Train* box)
- {
- if ((box->time_depch >= 7 && box->time_depch <= 9) && (box->dep == "Москва" && box->dist == "Санкт-Петербург"))
- {
- cout << box->number << "\t\t" << box->dep << "\t\t\t" << box->dist
- << "\t\t" << box->time_depch << ":" << box->time_depmin
- << "\t\t\t" << box->time_ch << ":" << box->time_min << "\t\t"
- << box->ticket;
- cout << endl;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement