Question: //System Libraries Here #include //I/O Library using namespace std; //User Libraries Here //Global Constants Only, No Global Variables //Like PI, e, Gravity, or conversions //Function
//System Libraries Here #include//I/O Library using namespace std; //User Libraries Here //Global Constants Only, No Global Variables //Like PI, e, Gravity, or conversions //Function Prototypes Here int mrkRand(int=1<<15-1); //PSRNG repeating the same sequence int *fillAry(int); //Randomly fill a 1-D column array void prntAry(int *,int); //Print a 1-D array void destroy(int **,int *,int *,int);//Deallocate memory int *fillIdx(int); void mrkSort(int *,int *,int); //Use a database sort //Complete the following Function int**fillAry(int *,int); //Randomly fill a triangular array void prntAry(int **,int *,int *,int);//Print a triangular array //Program Execution Begins Here int main(int argc, char** argv) { //Declare all Variables Here int *col; //Pointer to column array int *indx; //Index Array to the Sort Routine int **trangl; //Pointer to triangular array int rowSize; //Number of Rows in the Array //Input or initialize values Here cout<<"Input the Number of Rows in the Array"< >rowSize; indx=fillIdx(rowSize); //Index used for Database Sort col=fillAry(rowSize); //Dynamic 1-D array,#Columns in each row trangl=fillAry(col,rowSize);//Dynamic triangular array //Output Located Here cout<<"The Column Array Size"< Number of rows // col -> Column array size n with number of columns in each row //Output // array -> 2D Triangular Array/Matrix int **fillAry(int *col,int rows){ int **array=new int*[rows]; for(int i=0;i Number of rows // col -> Column array size n with number of columns in each row // array -> 2D Triangular Array/Matrix void prntAry(int **array,int *col,int *indx,int rows){ for(int i=0;i array[indx[lst]]){ indx[pos]=indx[pos]^indx[lst]; indx[lst]=indx[pos]^indx[lst]; indx[pos]=indx[pos]^indx[lst]; } } } } void destroy(int **a,int *c,int *indx,int n){ //Delete every row of the triangular array for(int i=0;i -------------------------------------------------------------------------------------------------------
1. use the concepts to generate a random number of columns for each row.
2. then combine and output the rows from smallest number of columns to largest number of columns.
3. lastly, modify all your code to use a structure
struct TriMatx{
int size; //Represents the number of rows
int *col; //Represents the column array, i.e. number of columns for each row
int *indx; //Represents the index matrix which you can sort to use for display
int **data; //Represents the data contents of the Triangular matrix
}
fill and pass all info by the structure instead of the components to all your functions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
