Advertisement
Guest User

Fixed

a guest
Nov 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     size_t n;
  6.     cout << "Vyvedi razmera na masiva: ";
  7.     cin >> n;
  8.     int*array = new int[n];
  9.  
  10.     for (int i = 0; i < n; i++) {
  11.         cout << "Vyvedi elementi [" << i << "]=";
  12.         cin >> array[i];
  13.     }
  14.     cout << "\n Masivyt sled sortirane:\n |  ";
  15.     for (int temp, i = 0; i < n - 1; i++) {
  16.         for (int j = i + 1; j < n; j++) {
  17.             if (array[i] > array[j]) {
  18.                 temp = array[i];
  19.                 array[i] = array[j];
  20.                 array[j] = temp;
  21.             }
  22.         }
  23.     }
  24.     for (int i = 0; i < n; i++) {
  25.         cout << array[i] << " | ";
  26.     }
  27.     cout << endl;
  28.     delete[] array;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement