Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- size_t n;
- cout << "Vyvedi razmera na masiva: ";
- cin >> n;
- int*array = new int[n];
- for (int i = 0; i < n; i++) {
- cout << "Vyvedi elementi [" << i << "]=";
- cin >> array[i];
- }
- cout << "\n Masivyt sled sortirane:\n | ";
- for (int temp, i = 0; i < n - 1; i++) {
- for (int j = i + 1; j < n; j++) {
- if (array[i] > array[j]) {
- temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
- }
- }
- for (int i = 0; i < n; i++) {
- cout << array[i] << " | ";
- }
- cout << endl;
- delete[] array;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement