Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- #include <cstdio>
- using namespace std;
- struct AEROFLOT {
- string NCity;
- int Num;
- string Type;
- };
- int main()
- {
- AEROFLOT Flot[7];
- setlocale(LC_ALL, "Russian");
- for (int i = 0; i < 7; i++){
- cout << "Введите номер:";
- cin >> Flot[i].Num;
- cout << "Введите тип самолета:";
- cin >> Flot[i].Type;
- cout << "Введите город:";
- cin >> Flot[i].NCity;
- cout << "-------------------------------------\n";
- }
- int tempN; string tempS;
- for (int i = 0; i < 7 - 1; i++) {
- for (int j = 0; j < 7 - i - 1; j++) {
- if (Flot[j].Num > Flot[j + 1].Num) {
- // меняем элементы местами
- tempN = Flot[j].Num;
- Flot[j].Num = Flot[j + 1].Num;
- Flot[j + 1].Num = tempN;
- tempS = Flot[j].NCity;
- Flot[j].NCity = Flot[j + 1].NCity;
- Flot[j + 1].NCity = tempS;
- tempS = Flot[j].Type;
- Flot[j].Type = Flot[j + 1].Type;
- Flot[j + 1].Type = tempS;
- }
- }
- }
- for (int i = 0; i < 7; i++) {
- for (int j = 0; j < 7; j++) {
- if (Flot[i].NCity == Flot[j].NCity && i != j) {
- cout << "Номера самолетов летящих в один город: " << Flot[i].Num << ", " << Flot[j].Num << "\n" << "Типы самолетов: " << Flot[i].Type << ", " << Flot[j].Type << endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement