-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1197.cpp
More file actions
27 lines (26 loc) · 793 Bytes
/
1197.cpp
File metadata and controls
27 lines (26 loc) · 793 Bytes
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
#include <string>
#include <iostream>
using namespace std;
int main()
{
int n, i, x, y;
string s,f;
cin >> n;
for (i = 0;i<n;i++)
{
int q = 0;
cin >> s;
x = s[0] - 'a' + 1;
y = s[1] - '0';
if ((x + 2 > 0) && (x + 2 < 9) && (y + 1 > 0) && (y + 1 < 9)) q++;
if ((y + 2 > 0) && (y + 2 < 9) && (x + 1 > 0) && (x + 1 < 9)) q++;
if ((y + 2 > 0) && (y + 2 < 9) && (x - 1 > 0) && (x - 1 < 9)) q++;
if ((y - 2 > 0) && (y - 2 < 9) && (x + 1 > 0) && (x + 1 < 9)) q++;
if ((y - 2 > 0) && (y - 2 < 9) && (x - 1 > 0) && (x - 1 < 9)) q++;
if ((x + 2 > 0) && (x + 2 < 9) && (y - 1 > 0) && (y - 1 < 9)) q++;
if ((x - 2 > 0) && (x - 2 < 9) && (y + 1 > 0) && (y + 1 < 9)) q++;
if ((x - 2 > 0) && (x - 2 < 9) && (y - 1 > 0) && (y - 1 < 9)) q++;
cout << q << endl;
}
return 0;
}