-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection.cpp
More file actions
35 lines (26 loc) · 732 Bytes
/
selection.cpp
File metadata and controls
35 lines (26 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<bits/stdc++.h>
using namespace std;
/***************************************ORIGINAL aUTHOR*******************************
*************************************************************************************
*************************************************************************************
*************astrainL3gi0N**********************************************************/
int main()
{
int n; cin>>n;
int arr[100];
for(int i = 0; i < n; ++i){
cin>>arr[i];
}
for(int i = 0; i < n; ++i){
int min = i;
for(int j = i+1; j < n; ++j){
if(arr[i] > arr[j]) min = j;
}
int temp = arr[min];
arr[min] = arr[i];
arr[i] = temp;
}
for(int i = 0; i < n; ++i)
cout<<arr[i]<<' ';
return 0;
}