#include #include #include // for rand() #include using namespace std; const int LOW =-15; //global const for the lower limit const int UP = 15; //global const for the upper limit const int ROW = 5; const int COL = 4; void GenerateArray(int[][COL], int, int, int, int); //function prototype void Print(int[][COL], int, int); bool AllPositive(int[][COL], int, int); void main(){ //declare and initialize array // int ROW=5; // int COL=4; int table[ROW][COL]; srand(time(NULL)); GenerateArray(table, ROW, COL, UP, LOW); //function call cout << "The original table is: "; Print(table, ROW, COL); cout << "Start subarray processing? (Y/N): "; cout << "Enter # of rows: "; cin >> ROW; cout << "Enter # of columns: "; cin >> COL; Print(table, ROW, COL); cout << endl; } // end program void GenerateArray (int a[][COL], int row, int col, int upper_limit, int lower_limit){ for (int r = 0; r < row; r++) for (int c = 0; c < col; c++) a[r][c] = rand()%(upper_limit - lower_limit + 1) + lower_limit; } void Print(int a[][COL], int row, int col){ for ( int r = 0; r < row; r++ ) { cout << endl; for ( int c = 0; c < col; c++ ) cout << setw(5) << a[r][c]; } } bool AllPositive(int a[][COL], int row, int col){ for ( int r = 0; r < row; r++ ) for ( int c = 0; c < col; c++ ) if(a[r][c] < 0) return false; return true; }