|
|
вернуться в форумac c++ #include <iostream> #include <stdio.h> #include <vector> using namespace std; class Place { public: char x; int y;
bool isOnboard() { if (x < 'a' || x > 'h' || y < 1 || y > 8) return false; return true; }
Place(char x, int y) { this->x = x; this->y = y; }
}; int main(int argc, const char * argv[]) { int N; cin >> N;
vector<Place> places;
for (int i = 0; i < N; i++) { char x; int y; cin.get(x);
if (x == '\n') { i--; continue; }
cin >> y;
Place place (x, y); places.push_back(place);
}
for (int i = 0; i < N; i++) { Place place = places[i]; int moves = 0;
//left 2 up 1 place.x -= 2; place.y -= 1; moves += place.isOnboard();
//left 2 down 1 place.y += 2; moves += place.isOnboard();
//right 2 down 1 place.x += 4; moves += place.isOnboard(); //right 2 up 1 place.y -= 2; moves += place.isOnboard(); //right 1 up 2 place.x -= 1; place.y -= 1; moves += place.isOnboard(); //left 1 up 2 place.x -= 2; moves += place.isOnboard(); //left 1 down 2 place.y += 4; moves += place.isOnboard(); //right 1 down 2 place.x += 2; moves += place.isOnboard();
cout << moves << endl;
}
} Edited by author 24.01.2014 20:07 |
|
|