Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main()
- {
- int a;
- cin >> a;
- string xy;
- int count1, count2;
- int count = 0;
- for (int x = 0; x < a; x++) {
- cin >> xy;
- count2 = xy[1] - (int)'0';
- if (xy[0] == 'a') {
- count1 = 1;
- }
- else if (xy[0] == 'b') {
- count1 = 2;
- }
- else if (xy[0] == 'c') {
- count1 = 3;
- }
- else if (xy[0] == 'd') {
- count1 = 4;
- }
- else if (xy[0] == 'e') {
- count1 = 5;
- }
- else if (xy[0] == 'f') {
- count1 = 6;
- }
- else if (xy[0] == 'g') {
- count1 = 7;
- }
- else if (xy[0] == 'h') {
- count1 = 8;
- }
- if (count1 + 2 <= 8) {
- if (count2 - 1 > 0)
- count++;
- if (count2 + 1 < 9)
- count++;
- }
- if (count1 - 2 >= 1) {
- if (count2 - 1 > 0)
- count++;
- if (count2 + 1 < 9)
- count++;
- }
- if (count2 - 2 > 0) {
- if (count1 - 1 > 0)
- count++;
- if (count1 + 1 < 9)
- count++;
- }
- if (count2 + 2 < 9) {
- if (count1 - 1 > 0)
- count++;
- if (count1 + 1 < 9)
- count++;
- }
- cout << count << endl;
- count = 0;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement