Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int q;
  9.     cin >> q;
  10.  
  11.     for (int x = 0; x < q; x++)
  12.     {
  13.         string s;
  14.         cin >> s;
  15.  
  16.         vector<int> pos(2, 0);
  17.         for (int i = 0; i < 2; i++)
  18.         {
  19.             if (s[i] == '1' || s[i] == 'a')
  20.             {
  21.                 pos[i] = 1;
  22.             }
  23.             if (s[i] == '2' || s[i] == 'b')
  24.             {
  25.                 pos[i] = 2;
  26.             }
  27.             if (s[i] == '3' || s[i] == 'c')
  28.             {
  29.                 pos[i] = 3;
  30.             }
  31.             if (s[i] == '4' || s[i] == 'd')
  32.             {
  33.                 pos[i] = 4;
  34.             }
  35.             if (s[i] == '5' || s[i] == 'e')
  36.             {
  37.                 pos[i] = 5;
  38.             }
  39.             if (s[i] == '6' || s[i] == 'f')
  40.             {
  41.                 pos[i] = 6;
  42.             }
  43.             if (s[i] == '7' || s[i] == 'g')
  44.             {
  45.                 pos[i] = 7;
  46.             }
  47.             if (s[i] == '8' || s[i] == 'h')
  48.             {
  49.                 pos[i] = 8;
  50.             }
  51.         }
  52.         /*for (int i = 0; i < 2; i++)
  53.         {
  54.             cout << pos[i] << " ";
  55.         }
  56.         cout << endl;*/
  57.  
  58.         int all = 8;
  59.  
  60.         while (true)
  61.         {
  62.             if ((pos[1] == 2 || pos[1] == 7) && (pos[0] == 2 || pos[0] == 7))
  63.             {
  64.                 all = 4;
  65.                 break;
  66.             }
  67.             if ((pos[1] == 1 || pos[1] == 8) && (pos[0] == 1 || pos[0] == 8))
  68.             {
  69.                 all = 2;
  70.                 break;
  71.             }
  72.  
  73.             if ((pos[0] == 1 || pos[1] == 1) || (pos[0] == 8 || pos[1] == 8))
  74.             {
  75.                 all = 4;
  76.                 break;
  77.             }
  78.             if ((pos[0] == 2 || pos[1] == 2) || (pos[0] == 7 || pos[1] == 7))
  79.             {
  80.                 all = 6;
  81.                 break;
  82.             }
  83.             else {
  84.                 break;
  85.             }
  86.         }
  87.  
  88.         cout << all << endl;
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement