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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started