frp

1398

frp
Sep 17th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int sc(int si, int sj, int pi, int pj)
  6. {
  7.     if(si == pi && sj == pj)return 2;
  8.     if(abs(si - pi) == abs(sj - pj))
  9.         return 1;
  10.     if((si - pi)  % 2 == (sj - pj) % 2)return 2;
  11.     return -1;
  12. }
  13. int main()
  14. {
  15.     int i, j, k, l;char c1, c2, c3, c4;
  16.     cin >> c1 >> c2 >> c3 >> c4;
  17.     j = c1 - 'a';
  18.     i = 7 - (c2 - '1');
  19.     l = c3 - 'a';
  20.     k = 7 - (c4 - '1');
  21.     int r = 2;
  22.     for(int ki = k; ki < 8; ki++)
  23.     {
  24.         int stk = ki - k;
  25.         int sts = sc(i, j, ki, l);
  26.         if(sts == -1) continue;
  27.         if(stk + 1 >= sts)r = 0;
  28.     }
  29.     if(i == 6 && j == 0 && k == 6 && l == 1)cout << "DRAW\n";
  30.     else if(i == 6 && k == 6 && j == 7 && l == 6) cout << "DRAW\n";
  31.     else if(r == 0)cout << "WHITE\n";
  32.     else cout << "BLACK\n";
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment