A. King Moves
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard outputThe only king stands on the standard chess board. You are given his position in format "cd", wherec is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.
Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).

King moves from the position e4
Input
The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.
Output
Print the only integer x — the number of moves permitted for the king.
Example
Input
e4
Output
8
解:国际象棋中的王可以上下左右斜方向进行移动,给定两个字符代表王所在的位置,加之判断四个特殊情况即可。
#include<stdio.h>
#include<string.h>
int main()
{
char a[2];
while(gets(a)){
int x=8;
if(a[0]=='a' || a[0]=='h'){
x-=3;
}
if(a[1]=='1' || a[1]=='8'){
x-=3;
}
if((a[0]=='a' && a[1]=='1') || (a[0]=='a' && a[1]=='8') ||(a[0]=='h' && a[1]=='1') || (a[0]=='h' && a[1]=='8')){
x+=1;
}
printf("%d\n",x);
}
return 0;
}