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
|
#include <iostream>
#include <iomanip>
using namespace std;
const int NUMCOLS=4;
const int TBLlROWS = 3;
const int TBL2ROWS = 4;
void showArray ( const int array[][NUMCOLS], int );
int main()
{
int tablel[TBLlROWS][NUMCOLS] ={{1,2,3,4},
{5,6,7,8},
{9,10,11,12}};
int table2[TBL2ROWS][NUMCOLS] = {{10,20,30,40},
{52,62,72,82},
{99,104,117,123}};
cout <<"The contents of tablel are:"<<"\n";
showArray(tablel, TBLlROWS);
cout << "\nThe contents of table2 are: \n";
showArray(table2, TBL2ROWS);
return 0;
}
void showArray(int const array[][NUMCOLS], int numRows)
{
for(int row=0;row<numRows;row++)
{
for(int col=0;col < NUMCOLS; col++)
{
cout << setw(5) << array[row][col] <<" ";
}
cout << endl;
}
}
|