Hey everyone.
I need to write some code that takes a two deimensional array, makes it a single dimension array and then sorts in ascending order. I need some help with the flatten part and here is what I have so far.
This code compiles and executes fine via Dev C++
Code:#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
const int NROWS = 4;
const int NCOLS = 5;
int i, j, s;
int first[NROWS][NCOLS] = {16,22,99,4,18,-258,4,101,5,98,105,6,15,2,45,33,88,72,16,3};
int SORT [19]; //Array of numbers
int sort; //Temp array number
// Insert the elements from the 2-dimmension in a single
for (i = 0; i < NROWS; i++)
{ //beginning of outer loop
cout << endl; //start each row on a new line
for (j = 0; j < NCOLS; j++)
{ //beginning of inner loop
SORT[0]=first[i][j];
cout << sort << endl;
} //end of inner loop
} //end of outer loop
cout << endl;
return 0;
}
