-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path275A.cpp
More file actions
52 lines (48 loc) · 1.03 KB
/
275A.cpp
File metadata and controls
52 lines (48 loc) · 1.03 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
50
51
52
#include <iostream>
using namespace std;
int toggle(int a)
{
if(a==0)
return 1;
else
return 0;
}
int main()
{
int matrix[3][3], output[3][3];
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
cin>>matrix[i][j];
output[i][j]=1;
}
}
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
if(matrix[i][j]%2)
{
output[i][j]=toggle(output[i][j]);
if(j<2)
output[i][j+1]=toggle(output[i][j+1]);
if(j>0)
output[i][j-1]=toggle(output[i][j-1]);
if(i<2)
output[i+1][j]=toggle(output[i+1][j]);
if(i>0)
output[i-1][j]=toggle(output[i-1][j]);
}
}
}
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
cout<<output[i][j];
}
cout<<endl;
}
return 0;
}