|
|
back to boardРаботающая версия [Worked] #include <iostream> #include <string> #include <vector> using namespace std; int test_horse(int, int); int test(string); int test(string run) { return test_horse(run[0] - 'a', run[1] - '1'); } int test_horse(int x, int y) { int count = 0; if(x + 1 < 8 && y + 2 < 8) {count++;} if(x + 1 < 8 && y - 2 >= 0) {count++;} if(x - 1 >= 0 && y + 2 < 8) {count++;} if(x - 1 >= 0 && y - 2 >= 0) {count++;}
if(x + 2 < 8 && y + 1 < 8) {count++;} if(x + 2 < 8 && y - 1 >= 0) {count++;} if(x - 2 >= 0 && y + 1 < 8) {count++;} if(x - 2 >= 0 && y - 1 >= 0) {count++;}
return count; } int main() { vector<string>vec;
int N; cin >> N;
for(int i = 0; i < N; ++i) { string str; cin >> str; vec.push_back(str); }
for(int i = 0; i < vec.size(); ++i) { cout << test(vec[i]) << endl; }
} |
|
|