Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main() {
- int n, cnt = 0;
- cin >> n;
- char a[2];
- for (int i = 0; i < n; i++) {
- cnt = 0;
- cin >> a;
- a[0] = (int)a[0] - 96;
- a[1] = a[1] - '0';
- for (int i = -2; i < 3; i++) {
- for (int j = -2; j < 3; j++) {
- if ((abs(i) + abs(j) == 3) && (a[0] + i > 0) && (a[1] + j > 0) && (a[0] + i < 9) && (a[1] + j < 9))
- cnt++;
- }
- }
- cout << cnt << '\n';
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement