-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwodim_recur_6.cpp
53 lines (46 loc) · 1.14 KB
/
twodim_recur_6.cpp
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
//Creation of Null Matrix through recursion
#include <iostream>
int createNullMatrix(int [][10], int, int, int, int );
void display(int, int, int[][10]);
using namespace std;
int main()
{
int a[10][10];
int m1, n1;
cout << "Enter row for Matrix : " << endl;
cin >> m1;
cout << "Enter columns for Matrix : " << endl;
cin >> n1;
createNullMatrix(a, m1, n1, 0, 0);
cout << "Displaying Matrix:" << endl;
display(m1, n1, a);
return 0;
}
int createNullMatrix(int array[][10], int rows, int columns, int i, int j)
{
if (i < rows)
{
if (j < columns)
{
array[i][j] = 0;
createNullMatrix(array, rows, columns, i, j + 1);
}
else
{
createNullMatrix(array, rows, columns, i + 1, 0);
}
}
return array[rows][10];
}
void display(int rows, int columns, int array[][10])
{
for (int i = 0; i < rows; i++)
{
cout << "|";
for (int j = 0; j < columns; j++)
{
cout << array[i][j] << " ";
}
cout << "|" << endl;
}
}