Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7.     int a;
  8.     cin >> a;
  9.     string xy;
  10.     int count1, count2;
  11.     int count = 0;
  12.     for (int x = 0; x < a; x++) {
  13.         cin >> xy;
  14.         count2 = xy[1] - (int)'0';
  15.         if (xy[0] == 'a') {
  16.             count1 = 1;
  17.         }
  18.         else if (xy[0] == 'b') {
  19.             count1 = 2;
  20.         }
  21.         else if (xy[0] == 'c') {
  22.             count1 = 3;
  23.         }
  24.         else if (xy[0] == 'd') {
  25.             count1 = 4;
  26.         }
  27.         else if (xy[0] == 'e') {
  28.             count1 = 5;
  29.         }
  30.         else if (xy[0] == 'f') {
  31.             count1 = 6;
  32.         }
  33.         else if (xy[0] == 'g') {
  34.             count1 = 7;
  35.         }
  36.         else if (xy[0] == 'h') {
  37.             count1 = 8;
  38.         }
  39.         if (count1 + 2 <= 8) {
  40.             if (count2 - 1 > 0)
  41.                 count++;
  42.             if (count2 + 1 < 9)
  43.                 count++;
  44.             }
  45.         if (count1 - 2 >= 1) {
  46.             if (count2 - 1 > 0)
  47.                 count++;
  48.             if (count2 + 1 < 9)
  49.                 count++;
  50.         }
  51.         if (count2 - 2 > 0) {
  52.             if (count1 - 1 > 0)
  53.                 count++;
  54.             if (count1 + 1 < 9)
  55.                 count++;
  56.         }
  57.         if (count2 + 2 < 9) {
  58.             if (count1 - 1 > 0)
  59.                 count++;
  60.             if (count1 + 1 < 9)
  61.                 count++;
  62.         }
  63.         cout << count << endl;
  64.         count = 0;
  65.         }
  66.    
  67.     system("pause");
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement