Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- //resubmission
- int main()
- {
- int i,n,x,y,cnt;
- char c[10];
- scanf("%d",&n);
- for(i=0;i<n;i++){
- scanf("%s",c);
- x=c[0]-96;
- y=c[1]-48;
- cnt=0;
- if(x+2<=8 && y+1<=8)
- cnt++;
- if(x+1<=8 && y+2<=8)
- cnt++;
- if(x-1>=1 && y+2<=8)
- cnt++;
- if(x-2>=1 && y+1<=8)
- cnt++;
- if(x-2>=1 && y-1>=1)
- cnt++;
- if(x-1>=1 && y-2>=1)
- cnt++;
- if(x+1<=8 && y-2>=1)
- cnt++;
- if(x+2<=8 && y-1>=1)
- cnt++;
- printf("%d\n",cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement