vincegeratorix

selection sort bien tabulado y con llaves

Dec 18th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. void ordenamiento(int a[], int n)
  2. //a es el arreglo a ordenar y n la cantidad de números que tiene (como fue declarado: a[n])
  3. //es void porque al pasar el arreglo pasa por referencia
  4. {
  5.     int i, j, min, tmp;
  6.     for(i=0; i<n-1; i++)
  7.     {
  8.         min=i;
  9.         for(j=i+1;j<n; j++)
  10.         {
  11.             if(a[j]<a[min])
  12.             {
  13.                 min=j;
  14.             }
  15.         }
  16.         tmp=a[i];
  17.         a[i]=a[min];
  18.         a[min]=tmp;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment