Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct Trains
- {
- string city;
- int number;
- int hours;
- int minutes;
- void input()
- {
- cout « "=================================================" « endl;
- cout « "Пункт назначения: "; cin » city;
- cout « "Номер поезда: "; cin » number;
- cout « "Время отправления." « endl;
- cout « "Часы: "; cin » hours;
- cout « "Минуты: "; cin » minutes;
- cout « "=================================================" « endl;
- }
- void output()
- {
- cout « "________________________________________________" « endl;
- cout « "Пункт назначения: " « city « endl;
- cout « "Номер поезда: " « number « endl;
- cout « "Время отправления." « endl;
- cout « "Часы: " « hours « endl;
- cout « "Минуты: " « minutes « endl;
- cout « "________________________________________________" « endl;
- }
- };
- int main()
- {
- const int n = 3;
- setlocale(LC_ALL, "Russian");
- Trains a[n];
- Trains tmp;
- int i, j;
- bool flag = false;
- int search;
- cout « "Ввод информации" « endl;
- for ( i = 0; i < n; i++)
- {
- cout « "Поезд " « endl;
- a[i].input();
- }
- for ( i = 0; i < n-1; i++)
- {
- for ( j = 0; j < n-1-i; j++)
- {
- if (a[j].number > a[j + 1].number)
- {
- tmp = a[j];
- a[j] = a[j+1];
- a[j+1] = tmp;
- }
- }
- }
- cout « "Отсортированный список:\n";
- for ( i = 0; i < 3; i++){
- a[i].output();
- }
- int input = 1;
- while (input)
- {
- flag = false;
- cout « "\nВведите номер поезда: ";
- cin » search;
- for (i = 0; i < 3; i++)
- {
- if (a[i].number == search)
- {
- flag = true;
- a[i].output();
- }
- }
- if (!flag)
- cout « "Извините, по вашему запросу ничего не найдено." « endl;
- cout « "\nХотите продолжить поиск (1 -да, 0 -нет) ";
- cin » input;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement