Advertisement
OMEGAHEAD_MonkoX

TAKE MY HORSE TO THE OLD TOWN CHESS

Nov 1st, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cstring>
  5. #include <sstream>
  6. #include <string>
  7. #include <algorithm>
  8. using namespace std;
  9.  
  10.  
  11. int main()
  12. {
  13.     int i,n,j,chi,chj;
  14.     string b,bu,etalon,TWOHEAD;
  15.     n=8;
  16.     vector<vector<char>> a(n, vector<char>(n,'.'));
  17.     cin >> b;
  18.     etalon="abcdefgh";
  19.     bu=b[0];
  20.     TWOHEAD=b[1];
  21.     chi=stoi(TWOHEAD);
  22.     chj=etalon.find(bu);
  23.     chi=n-chi;
  24.     a[chi][chj]='K';
  25.     if (chj+1<n & chi-2>=0)
  26.         a[chi-2][chj+1]='*';
  27.     if (chj-1>=0 & chi-2>=0)
  28.         a[chi-2][chj-1]='*';
  29.     if (chj+2<n & chi-1>=0)
  30.         a[chi-1][chj+2]='*';
  31.     if (chj+2<n & chi+1<n)
  32.         a[chi+1][chj+2]='*';
  33.     if (chj+1<n & chi+2<n)
  34.         a[chi+2][chj+1]='*';
  35.     if (chj-1>=0 & chi+2<n)
  36.         a[chi+2][chj-1]='*';
  37.     if (chj-2>=0 & chi+1<n)
  38.         a[chi+1][chj-2]='*';
  39.     if (chj-2>=0 & chi-1>=0)
  40.         a[chi-1][chj-2]='*';
  41.     for(i=0;i<n;++i)
  42.     {
  43.         for(j=0;j<n;++j)
  44.             cout<<a[i][j] << " ";
  45.         cout<<endl;
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement