SHARE
TWEET

Untitled

a guest May 23rd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void countSort(char arr[])
  2. {
  3.  
  4.     char output[strlen(arr)];
  5.  
  6.     int count[RANGE +1], i;
  7.     memset(count,0, sizeof(count));
  8.  
  9.  
  10.     for(i = 0; arr[i]; ++i)
  11.         ++count[arr[i]];
  12.  
  13.     for(i = 1;i <= RANGE; ++i)
  14.         count[i] += count[i-1];
  15.  
  16.  
  17.     for(i=0;arr[i];++i)
  18.     {
  19.         output[count[arr[i]]-1] = arr[i];
  20.         --count[arr[i]];
  21.     }
  22.     for (i=0; arr[i]; ++i)
  23.             arr[i] = output[i];
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top