Question: Problem #2 (All Kinds of Sorting) Sort a single column array and/or sort a 2 dimensional array of characters given any column. Here is what

Problem #2 (All Kinds of Sorting)

Sort a single column array and/or sort a 2 dimensional array

of characters given any column. Here is what I used as my

template specification.

//This class sorts arrays either ascending or descending

template

class Prb2Srt

{

private:

int *index; //Index that is utilized in the sort

public:

Prb2Srt(){index=NULL;}; //Constructor

~Prb2Srt(){delete []index;}; //Destructor

T *srtArry(const T*,int,bool); //Sorts a single column array

T *srtArry(const T*,int,int,int,bool); //Sorts a 2 dimensional array represented as a 1 dim array

};

Driver program for the above class. Create your own file to read.

cout<<"The start of Problem 2, the sorting problem"<

Prb2Srt rc;

bool ascending=true;

ifstream infile;

infile.open("Problem2.txt",ios::in);

char *ch2=new char[10*16];

char *ch2p=ch2;

while(infile.get(*ch2)){cout<<*ch2;ch2++;}

infile.close();

cout<

cout<<"Sorting on which column"<

int column;

cin>>column;

char *zc=rc.srtArry(ch2p,10,16,column,ascending);

for(int i=0;i<10;i++)

{

for(int j=0;j<16;j++)

{

cout<

}

}

delete []zc;

cout<

The output from this problem.

The start of Problem 2, the sorting problem

Lbekoeddhoffbmi

Lkcmggjcdhhglif

Cgldjhcekjigcdd

Cgldjhcekjigcdm

Bffmdbkcenlafjk

Fggdijijegfblln

Jjlncnimjldfedj

Amliglfohajcdmn

Balgfcaelhfkgeb

Kmlhmhcddfoeilc

Sorting on column 15

Cgldjhcekjigcdm

Fggdijijegfblln

Amliglfohajcdmn

Bffmdbkcenlafjk

Jjlncnimjldfedj

Lbekoeddhoffbmi

Lkcmggjcdhhglif

Cgldjhcekjigcdd

Kmlhmhcddfoeilc

Balgfcaelhfkgeb

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!