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
|
//David Scheip
//Created 4.27.13
//Page 523 Number 3
//Use a nested for loop to print array a[3][2] and a nested while loop to print array b[2][3]
//defined here and print both in matrix form:
//int a[3][2] = {11,22,33,44,55,66}; b[2][3] = {111,222,333,444,555,666}
#include <iostream>
using namespace std;
int main()
{
int a[3][2] = {11,22,33,44,55,66},
b[2][3] = {111,222,333,444,555,666},
i, j, l;
int k = 0;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
while(k <=2)
{
l=0;
while(l <=3)
{
cout << b[k][l] << " ";
++l;
}
++k;
cout << endl;
}
cin.get();
}
|