-
Notifications
You must be signed in to change notification settings - Fork 2
/
beautifulmatrix.cpp
42 lines (42 loc) · 1003 Bytes
/
beautifulmatrix.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
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[5][5];
for(int i=0;i<5;i++)
for(int j=0;j<5;j++)
cin>>a[i][j];
int count=0;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if(a[i][j]==1)
{
if(i==2&&j==2)
{
count=0;
}
else if(j==2&&i>2)
count+=i-2;
else if(j>2&&i==2)
count+=j-2;
else if(j==2&&i<2)
count+=2-i;
else if(i==2&&j<2)
count+=2-j;
else if(i>2&&j>2)
count+=(i-2)+(j-2);
else if(i<2&&j<2)
count+=(2-i)+(2-j);
else if(i<2&&j>2)
count+=(2-i)+(j-2);
else if(i>2&&j<2)
count+=(i-2)+(2-j);
cout<<count<<endl;
exit(0);
}
}
}
}