Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void main(void){
- //selection
- int const n = 5;
- int input[n] = {5,4,3,1,2};
- for(int i=0; i<n-1;i++){
- int min = i;
- for (int j=i+1;j<n;j++){
- if (input[j]<input[min]){
- min = j;
- }
- }
- if(min != i){
- swap(input[min],input[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement