Need Help With 2D Arrays
May 29, 2013 at 8:17pm May 29, 2013 at 8:17pm UTC
hey guys, I'm trying to solve the following problem set
https://www.dropbox.com/s/uj2kd8a764v7txy/Problem%20Set.pdf
I have the following code so far, I need help with creating a function that finds the largest product inside the array and also with error handling part. Something's not write with the following code as it does not output the correct matrix according to user input. Need help debugging that too.
Thank you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
using namespace std;
void create_array( void );
int main(){
cout << "WELCOME!" << endl;
create_array();
return 0;
}
void create_array( void ) // Function that creates the Array
{
int col , row;
cout << "Columns\n> " << flush;
cin >> col;
cout << "Rows\n> " << flush;
cin >> row;
int array[row][col];
srand(time(NULL)); // Generate Random Numbers
for ( int i = 0; i <col; ++i )
{
for ( int j = 0; j <row; ++j )
{
array [row][col]= (rand() % 100) + 1;
cout << array[row][col] << endl;
}
cout<< endl;
}
}
Topic archived. No new replies allowed.