-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MidRC_matrice.cpp
62 lines (62 loc) · 1.03 KB
/
MidRC_matrice.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
54
55
56
57
58
59
60
61
62
#include<iostream>
using namespace std;
int main()
{
int m, n,odd;
int arr[100][100];
cout << "Enter the rows : ";
cin >> m;
cout << "Enter the cloumns : ";
cin >> n;
odd = (m - 1) / 2;
if (m == n && m%2!=0 && n%2!=0)
{
cout << "Elements of Array : " << endl;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
cin >> arr[i][j];
}
}
cout << "The Matrice is : " << endl;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
cout << "Middle Row is : "<<endl;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
if (odd==i)
{
cout << arr[i][j] << " ";
}
}
}
cout << endl;
cout << "Middle Column is : " << endl;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
if (odd == j)
{
cout << arr[i][j] << " ";
}
}
}
}
else
cout << "It is not a square matrice ";
return 0;
}