-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathdesen1.cpp
58 lines (54 loc) · 963 Bytes
/
desen1.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
#include<cstdio>
using namespace std;
int a[1002][1002],b[1002][1002],n,m;
void citire()
{
int i,j;
scanf ("%d%d", &n, &m);
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
scanf ("%d", &a[i][j]);
}
int stare(int i,int j)
{
int c=0;
if(b[i-1][j]+b[i-1][j-1]==1) c++;
if(b[i-1][j]+b[i-2][j]==1) c++;
if(b[i-1][j]+b[i-1][j+1]==1) c++;
return c;
}
void construieste()
{
int i,j;
for(i=2;i<n;i++)
for(j=2;j<m;j++)
if(stare(i,j)!=a[i-1][j])
b[i][j]=1-b[i-1][j];
else
b[i][j]=b[i-1][j];
}
void afisare()
{
int i,j;
for(i=1;i<=n;i++)
{
printf (".");
for(j=2;j<=m;j++)
{
if(b[i][j-1]!=b[i][j]) printf ("|");
else printf (".");
if(b[i+1][j]!=b[i][j]) printf ("_");
else printf (".");
}
printf ("\n");
}
}
int main()
{
freopen ("desen1.in", "r", stdin);
freopen ("desen1.out", "w", stdout);
citire();
construieste();
afisare();
return 0;
}