Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6. struct AEROFLOT {
  7.     string NCity;
  8.     int Num;
  9.     string Type;
  10. };
  11.  
  12. int main()
  13. {
  14.     AEROFLOT Flot[7];
  15.    
  16.     setlocale(LC_ALL, "Russian");
  17.     for (int i = 0; i < 7; i++){
  18.         cout << "Введите номер:";
  19.         cin >> Flot[i].Num;
  20.         cout << "Введите тип самолета:";
  21.         cin >> Flot[i].Type;
  22.         cout << "Введите город:";
  23.         cin >> Flot[i].NCity;
  24.         cout << "-------------------------------------\n";
  25.  
  26.     }
  27.  
  28.     int tempN; string tempS;
  29.     for (int i = 0; i < 7 - 1; i++) {
  30.         for (int j = 0; j < 7 - i - 1; j++) {
  31.             if (Flot[j].Num > Flot[j + 1].Num) {
  32.                 // меняем элементы местами
  33.                 tempN = Flot[j].Num;
  34.                 Flot[j].Num = Flot[j + 1].Num;
  35.                 Flot[j + 1].Num = tempN;
  36.  
  37.                 tempS = Flot[j].NCity;
  38.                 Flot[j].NCity = Flot[j + 1].NCity;
  39.                 Flot[j + 1].NCity = tempS;
  40.  
  41.                 tempS = Flot[j].Type;
  42.                 Flot[j].Type = Flot[j + 1].Type;
  43.                 Flot[j + 1].Type = tempS;
  44.             }
  45.         }
  46.     }
  47.  
  48.  
  49.  
  50.  
  51.     for (int i = 0; i < 7; i++) {
  52.         for (int j = 0; j < 7; j++) {
  53.             if (Flot[i].NCity == Flot[j].NCity && i != j) {
  54.                 cout << "Номера самолетов летящих в один город: " << Flot[i].Num << ", " << Flot[j].Num << "\n" << "Типы самолетов: " << Flot[i].Type << ", " << Flot[j].Type << endl;
  55.  
  56.             }
  57.         }
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement