Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ F8 Sort using a 2-Dimension Array of characters. 15pts Task-> Same as others which means implement the function prototypes to solve the problem. This

C++

F8 Sort using a 2-Dimension Array of characters. 15pts

Task-> Same as others which means implement the function prototypes to solve the problem.

This problem was solved in question 3 but it has a twist. Before you sorted with respect to the ascii table using string compare -> strcmp() from the library. You can use the same code but you will have to create your own strcmp(). The reason is you are going to change the sort order. This time you will input a character array to replace/swap values with another array. Then do the sort.

//System Libraries Here #include //cin,cout #include //strlen(),strcmp(),strcpy() using namespace std;

//Global Constants Only, No Global Variables //Allowed like PI, e, Gravity, conversions, array dimensions necessary const int COLMAX=80;//Only 20 required, and 1 for null terminator

//Function Prototypes Here int read(char [][COLMAX],int &);//Outputs row and columns detected from input void sort(char [][COLMAX],int,int,const char[],const char[]);//Sort by row using strcmp(); void print(const char [][COLMAX],int,int);//Print the sorted 2-D array //int strcmp(char a[],char b[],char replace[],char with[]){ int strcmp(char [],char [],const char [],const char []);//Replace sort order

//Program Execution Begins Here int main(int argc, char** argv) { //Declare all Variables Here const int ROW=30; //Only 20 required char array[ROW][COLMAX]; //Bigger than necessary int colIn,colDet,rowIn,rowDet;//Row, Col input and detected char replace[COLMAX],with[COLMAX];//New sort order //Input the new sort order then sort cout<<"Modify the sort order by swapping these characters."<>replace; cout<<"With the following characters"<>with; cout<<"Read in a 2 dimensional array of characters and sort by Row"<>rowIn; cout<<"Input the maximum number of columns <=20"<>colIn; //Now read in the array of characters and determine it's size rowDet=rowIn; cout<<"Now input the array."<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions

Question

In what ways does its structure help and hurt Abercrombie & Fitch?

Answered: 1 week ago