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 temp,j;
- for (int i = 0; i < n ; i++ ){
- j = i ;
- while(j>0 && arr[j]<arr[j-1]){
- temp = arr[j];
- arr[j] = arr[j-1];
- arr[j-1] = temp ;
- j--;
- }
- }
- cout<<"After Sorting"<<nl;
- for (int i = 0; i < n ; i++ ){
- cout<<arr[i]<<" ";
- }
- }
Add Comment
Please, Sign In to add comment