SHARE
TWEET

Untitled

ThaiPeen May 19th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Top