Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define nl '\n'
- int main(){
- int n = 10 , arr[n]={6,2,12,23,11,56,85,41,203,101};
- int indxMin,temp;
- cout<<"Before Sorting"<<nl;
- for (int i = 0; i < n ; i++ ){
- cout<<arr[i]<<" ";
- }
- cout<<nl<<nl;
- for (int i = 0; i < n-1 ; i++ ){
- indxMin = i;
- for (int j = i+1; j < n ; j++ ){
- if(arr[j] < arr[indxMin]){
- indxMin = j;
- }
- }
- if(indxMin != i){
- temp = arr[i];
- arr[i] = arr[indxMin];
- arr[indxMin] = temp;
- }
- }
- cout<<"After Sorting"<<nl;
- for (int i = 0; i < n ; i++ ){
- cout<<arr[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement