Robert_Manea

sortare prin insertie directa

Jan 15th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. void sortare(int v[30],int n)
  2.  
  3.  
  4. {int i,j,aux,term;
  5. for(i=0;i<n;i++){
  6. j=i-1;
  7. term=0;
  8. aux=v[i];
  9. do{
  10. if(aux<v[j]){
  11. v[j+1]=v[j];
  12. j--;
  13. }
  14. else term=1;
  15. }while((j!=-1)&&(!term));
  16. v[j+1]=aux;}
  17. for(i=0;i<n;i++)
  18. printf("%d ",v[i]);}
Advertisement
Add Comment
Please, Sign In to add comment