|
|
ifstream
by using the very similar istringstream
:
|
|
Odds: 39 49 59 81 89 93 93 95 99 Evens: 40 50 56 62 70 72 78 86 92 96 100 |
constexpr std::size_t MAXROWS{ 15 };
and the same for "MAXCOLS". Put this above main under the using namespace std;
that is best not to use. As a global variable both the functions and main have access to these variables.Enter The Number Of Rows 2 to 15
and the same concept for the columns. This way someone is less likely to enter a number that is beyond the size of the array. You should also follow each input with a check that the number entered is within the proper range.GetUserInput(int (&numArr)[MAXROWS][MAXCOLS])
. When passing by reference you have to tell the compiler the size of each dimension even a 1D array. Using the "MAXROWS" makes this very easy.
|
|
Enter The Number Of Rows 2 to 15: 20 error message Enter The Number Of Rows 2 to 15: 15 Enter The Number Of Columns 2 to 10: 15 error message Enter The Number Of Columns 2 to 10: 10 |
|
|
Enter The Number Of Rows 2 to 15: 15 Enter The Number Of Columns 2 to 10: 10 Even Elements From The 2-D ARRAY 44 60 76 98 76 64 26 94 28 66 24 32 66 18 90 90 56 48 84 80 46 64 32 48 96 90 94 82 48 66 94 22 20 56 92 6 34 72 66 40 26 10 70 18 4 6 94 82 84 42 38 60 66 54 98 32 52 70 78 82 44 66 90 48 28 10 28 94 100 60 22 8 84 92 Odd Elements From The 2-D ARRAY: 49 19 43 93 43 39 19 3 57 53 9 35 95 41 85 97 47 41 25 63 43 81 41 9 53 93 99 1 79 63 61 43 73 89 15 77 63 69 77 43 75 45 95 87 29 89 79 91 85 57 7 45 57 99 89 67 33 35 47 31 95 5 77 41 83 21 71 75 81 77 91 31 99 53 23 73 |