Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int i,j,n,temp;
- n =10;
- int a[]={90,145,67,23,189,29,334,92, 266, 95};
- cout<<"\n Data angka sebelum diurutkan"<<endl;
- for(i=0;i<n;i++)
- {
- cout<<a[i]<<" , ";
- }
- for(i=1;i<=n-1;i++)
- {
- temp=a[i];
- j=i-1;
- while((temp<a[j])&&(j>=0))
- {
- a[j+1]=a[j];
- j=j-1;
- }
- a[j+1]=temp; //insert element in proper place
- }
- cout<<"\n \n urut setelah inserting sort\n";
- for(i=0;i<n;i++)
- {
- cout<<a[i]<<" , ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment