Link to home
Start Free TrialLog in
Avatar of rhinez0rz
rhinez0rz

asked on

Radix Exchange Sorts that sorts strings in C++

I need an implementation of radix sort that works for strings in c++.
This is what I am using to generate the string randomly.

#include <iostream>
#include <cstdlib>
#define STRING_SIZE 11
#define ARRAY_SIZE 10

using std::cout;
using std::endl;

void generate(char ppt[][STRING_SIZE])
{
     for (int j=0; j<ARRAY_SIZE;j++)
     {
          for(int i =0; i<STRING_SIZE-1;i++)
          {
                  ppt[j][i] = rand()%2 + 'A';
          }
         ppt[j][STRING_SIZE-1]='\0';
     }
}

void print(char ppt[ARRAY_SIZE][STRING_SIZE])
{
    for(int i=0; i<ARRAY_SIZE; i++)
              cout << "ppt[" << i << "] = " << ppt[i] << endl;
}


int main()
{
    srand(time(0));
    char array[ARRAY_SIZE][STRING_SIZE];
    generate(array);
    print(array);
    system("pause");
    return 0;
}
ASKER CERTIFIED SOLUTION
Avatar of rajeev_devin
rajeev_devin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial