SHARE
TWEET

Task 4.3

a guest Oct 21st, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int size;
  8.     cin >> size;
  9.     int *elementsFirst = new int[size];
  10.     int *elementsSecond = new int[size];
  11.  
  12.     for (int i = 0; i < size; i++)
  13.         cin >> elementsFirst[i];
  14.  
  15.     for (int j = 0; j < size; j++)
  16.         cin >> elementsSecond[j];
  17.  
  18.     for (int j = 0; j < size - 1; j++) {
  19.         for (int i = 0; i < size - 1; i++)
  20.         {
  21.             if (elementsFirst[i] > elementsFirst[i + 1])
  22.             {
  23.                 swap(elementsFirst[i], elementsFirst[i + 1]);
  24.                 swap(elementsSecond[i], elementsSecond[i + 1]);
  25.             }
  26.         }
  27.     }
  28.  
  29.     for (int j = 0; j < size; j++)
  30.         cout << elementsFirst[j] << ' ';
  31.  
  32.     cout << '\n';
  33.  
  34.     for (int j = 0; j < size; j++)
  35.         cout << elementsSecond[j] << ' ';
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top