Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void main() {
  4.     setlocale(LC_ALL, "rus");
  5.     int n, p, schet = 0;
  6.     cout << "введите длину массива #1- "; cin >> n;
  7.     cout << "введите длину массива #2- "; cin >> p;
  8.     int* arr_1 = new int[n];
  9.     int* arr_2 = new int[p];
  10.     cout << "Введите числа 1 массива" << endl;
  11.     for (int q = 0; q < n; q++)
  12.     {
  13.         cin >> arr_1[q];
  14.     }
  15.     cout << "Введите числа 2 массива" << endl;
  16.     for (int q = 0; q < p; q++)
  17.     {
  18.         cin >> arr_2[q];
  19.     }
  20.     cout << "Одинаковые пары:" << endl;
  21.     for (int q = 0; q < n; q++)
  22.     {
  23.         int& l = arr_1[q];
  24.         int m = q;
  25.         for (int t = 0; t < p; t++)
  26.         {
  27.             if (l == arr_2[t])
  28.             {
  29.                 cout << m+1 << " - " << t+1 << endl;
  30.                 cout << l << " - " << arr_2[t]<<endl;
  31.                 cout <<  "--------------------" << endl;
  32.                 schet++;
  33.             }
  34.         }
  35.  
  36.     }
  37.     cout << "Количество пар - " << schet;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement