Advertisement
Guest User

Ordenacao por distribuicao

a guest
Nov 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. void troca(char **valores,int k,int l ,int d)
  2. {
  3.   char *tmp = calloc(d,sizeof(char *));
  4.   strcpy(tmp,valores[k]);
  5.   strcpy(valores[k],valores[l]);
  6.   strcpy(valores[l],tmp);
  7.   free(tmp);
  8. }
  9. void ord(char **v, int n,int d)
  10. {
  11.   int j,k,l,i;
  12.   for(i = d-1; i >= 0; i--)
  13.   {
  14.     for(j = 0, l = 0; j < 10;j++)
  15.     {
  16.       for(k = 0; k < n;k++)
  17.       {
  18.         if(v[k][i] - '0' == j)
  19.           troca(v,k,l,d);
  20.       }
  21.     }
  22.   }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement