-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlights_out.cpp
More file actions
49 lines (49 loc) · 1.2 KB
/
Copy pathlights_out.cpp
File metadata and controls
49 lines (49 loc) · 1.2 KB
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
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a[3][3] = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}};
int arr[3][3];
int r, c, temp;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{
cin >> arr[i][j];
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
if (arr[i][j] % 2 == 1)
{
a[i][j] = abs(a[i][j] - 1);
if ((i + 1) >= 0 && (i + 1) <= 2)
{
a[i + 1][j] = abs(a[i + 1][j] - 1);
}
if ((j + 1) >= 0 && (j + 1) <= 2)
{
a[i][j + 1] = abs(a[i][j + 1] - 1);
}
if ((i - 1) >= 0 && (i - 1) <= 2)
{
a[i - 1][j] = abs(a[i - 1][j] - 1);
}
if ((j - 1) >= 0 && (j - 1) <= 2)
{
a[i][j - 1] = abs(a[i][j - 1] - 1);
}
}
}
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << a[i][j];
}
cout << "\n";
}
return 0;
}