Question: answer the following question by modifying the attached code in CPP --------- code starts here -------------- //System Libraries Here #include //I/O Library using namespace std;

answer the following question by modifying the attached code in CPP

answer the following question by modifying the attached code in CPP ---------

--------- code starts here --------------

//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

//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>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

//Deallocate the array destroy(trangl,col,indx,rowSize); //Exit return 0; }

//Modify this Function for unequal number of columns per row //Input rows -> 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 array[i]=new int[rows]; } for(int i=0;i for(int j=0;j array[i][j]=mrkRand()%9+1;//1 Digit numbers [1-9] } } return array; }

//Modify this Function for unequal number of columns per row //Input n -> 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 for(int j=0;j cout

void mrkSort(int *array,int *indx,int size){ for(int pos=0;pos for(int lst=pos+1;lst if(array[indx[pos]]>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 delete a[i]; } //Delete the pointers delete []a; delete []c; delete []indx; }

void prntAry(int *a,int n){ for(int i=0;i cout

int *fillAry(int n){ int *array=new int[n]; for(int i=0;i array[i]=mrkRand()%9+1;//1 Digit numbers [1-9] } return array; }

int *fillIdx(int n){ int *array=new int[n]; for(int i=0;i array[i]=i; } return array; }

int mrkRand(int seed){ //Xn+1 = (aXn + c) mod m //where X is the sequence of pseudo-random values //m, 0

--------expected outcome--------------

code starts here -------------- //System Libraries Here #include //I/O Library using namespace

Take the template and complete creation and ordering of the Triangular Matrix. //Complete the following Functions int**fillAry(int *,int); [/Randomly fill a triangular array void prntAry(int **,int * int *,int);//Print a triangular array Expected Output Input-the-Number-of-Rows-in-the-Arrayd The-Column-Array-Sized 3.4.1-8-2-6-2-5-7.9 The-Triangular-Array-Sortede 9. 13-2-d 9.3. 19-4-3-4 9-8-2-3- 7.1.4.4.9. 3.9.2-4.5.4. 3-5-8-3-8.6.7.d 9-4-1-5.4.7.9.7. 5-5-6-2-4.7-6.6-1.4 t

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!