Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool in_border ( int x, int y )
- {
- return x >= 0 && x < 8 && y >= 0 && y < 8;
- }
- int main() {
- int n;
- cin >> n;
- int dx[8] = {1,1,-1,-1,2,2,-2,-2};
- int dy[8] = {2,-2,2,-2,1,-1,1,-1};
- while ( n-- )
- {
- char a, b;
- cin >> a >> b;
- a -= 'a';
- b -= '0' + 1;
- int count_of_moves = 0;
- for ( int i = 0 ; i < 8 ; i++ )
- count_of_moves += in_border(a + dx [ i ], b + dy [ i ]);
- cout << count_of_moves << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement