Created
July 24, 2017 11:19
-
-
Save MohamedTaha98/7f52e907a031d86b1f162be62399edd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main () { | |
int n; | |
cin >> n; | |
int ar[n]; | |
for (int i = 0; i < n; i++) | |
cin >> ar[i]; | |
for (int i = 0; i < n; i++) { | |
int min = i; | |
for (int j = i + 1; j < n; j++) { | |
if (ar[j] < ar[min]) | |
min = j; | |
} | |
if (min != i) { | |
int tmp = ar[min]; | |
ar[min] = ar[i]; | |
ar[i] = tmp; | |
} | |
} | |
for (int i = 0; i < n; i++) | |
cout << ar[i] << " "; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment