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 51 52 53 54 55 56 57 58 59
|
#include <iostream>
using namespace std;
int main()
{
int choice;
cout << "Enter your choice 3x3 or 4x4 :";
cin>> choice;
if (choice==3)
cout<< "You have chose 3x3 array" << endl;
int arrayA[3][3] = {{3,8,14},{13,3,20},{7,16,19}};
for (int i=0; i<3; i++)
{
cout<< endl; // to create a new row
for (int j=0; j<3; j++)
{
cout << arrayA[i][j] << " ";
}
}
int arrayB[3][3] = {{16,12,9},{27,12,15},{20,11,40}};
for (int i=0; i<3; i++)
{
cout<< endl; // to create a new row
for (int j=0; j<3; j++)
{
cout << arrayB[i][j] << " " ;
}
}
if (choice==4)
cout<< "You have chose 4x4 array \n" << endl;
int arrayC[4][4] = {{2,11,13,5},{6,11,17,33},{2,7,27,10},{10,36,12,8}};
for (int i=0; i<4; i++)
{
cout<< endl; // to create a new row
for (int j=0; j<4; j++)
{
cout << arrayC[i][j] << " ";
}
}
int arrayD[4][4] = {{8,4,7,9},{12,1,13,28},{16,5,24,36},{20,15,9,3}};
for (int i=0; i<4; i++)
{
cout<< endl; // to create a new row
for (int j=0; j<4; j++)
{
cout << arrayD[i][j] << " ";
}
}
return 0;
}
|