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"< 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<>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<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
