SHARE
TWEET

Task 4.2

a guest Oct 21st, 2019 65 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 sizeFirst;
  8.     cin >> sizeFirst;
  9.     int *elementsFirst = new int[sizeFirst];
  10.  
  11.     for (int i = 0; i < sizeFirst; i++)
  12.         cin >> elementsFirst[i];
  13.  
  14.     for (int i = 0; i < sizeFirst - 1; i++) {
  15.         int temp = elementsFirst[i];
  16.  
  17.         if (temp < elementsFirst[i + 1]){
  18.             elementsFirst[i] = elementsFirst[i + 1];
  19.             elementsFirst[i + 1] = temp;
  20.         }
  21.     }
  22.  
  23.     for (int i = 0; i < 4; i++)
  24.         cout << elementsFirst[i] << ' ';
  25. }
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