Advertisement
ThaiPeen

timus 1197

May 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main() {
  5.     int n, cnt = 0;
  6.     cin >> n;
  7.     char a[2];
  8.     for (int i = 0; i < n; i++) {
  9.         cnt = 0;
  10.         cin >> a;
  11.         a[0] = (int)a[0] - 96;
  12.         a[1] = a[1] - '0';
  13.         for (int i = -2; i < 3; i++) {
  14.             for (int j = -2; j < 3; j++) {
  15.                 if ((abs(i) + abs(j) == 3) && (a[0] + i > 0) && (a[1] + j > 0) && (a[0] + i < 9) && (a[1] + j < 9))
  16.                     cnt++;
  17.             }
  18.         }
  19.         cout << cnt << '\n';
  20.     }
  21.     system("pause");
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement