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
|
#include<iostream>
using namespace std;
void multidimensional(int **, int, int);
void result(int **, int, int);
int main()
{
int m, n;
cout << "Enter your rows and your columns: ";
cin >> m >> n;
int **matrix = new int*[m];
for (int i = 0; i < m; i++)
matrix[i] = new int[n];
multidimensional(matrix, m, n);
result(matrix, m, n);
system("pause>0");
return 0;
}
void multidimensional(int **matrix, int m, int n)
{
for (int i = 0; i < m; i++){
cout << "Enter " << n << " number<s> for your row number " << i << " : ";
for (int j = 0, element; j < n; j++){
cin >> element;
matrix[i][j] = element;
}
}
}
void result(int **matrix, int m, int n)
{
cout << endl;
cout << "Two dimensional board \n";
for (int i = 0; i < m; i++)
{
cout << endl;
for (int j = 0; j < n; j++)
cout << matrix[i][j] << " ";
}
}
|