ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1197. Lonesome Knight

Shortest Solution
Posted by MIA_KB_12 25 Mar 2012 19:23
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main() {
    int desk[][4] = { { 2, 3, 4, 4 }, { 3, 4, 6, 6 }, { 4, 6, 8, 8 }, { 4, 6,
            8, 8 } };
    int n;
    scanf("%d", &n);
    string str;
    getline(cin, str);
    char c, c1;
    int x, y;
    for (int i = 0; i < n; i++) {
        scanf("%c%c", &c, &c1);
        x = (c - 'a') > 3 ? 7 - (c - 'a') : (c - 'a');
        y = (c1 - '1') > 3 ? 7 - (c1 - '1') : (c1 - '1');
        printf("%d\n", desk[x][y]);
        getline(cin, str);
    }
    return 0;
}