Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sort(int p[], int n){
- if (n > 0) {
- int max = 0;
- for (int i = 0; i < n; i++) {
- if (p[i] < p[max])
- max = i;
- }
- int tmp = p[max];
- p[max] = p[n - 1];
- p[n - 1] = tmp;
- sort(p, n - 1);
- }
- }
- int main(){
- int n;
- cin >> n;
- int * p = new int[n];
- for (int i = 0; i < n; i++)
- cin >> p[i];
- sort(p, n);
- cout << endl;
- for (int i = 0; i < n; i++)
- cout << p[i] << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement