Advertisement
Farjana_akter

Untitled

Jan 30th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int t,i,r1,c1,j,r2,c2;
  5. char a[5];
  6. int r[8]={-2,-2,-1,-1,1,1,2,2};
  7. int c[8]={-1,1,-2,2,-2,2,-1,1};
  8. scanf("%d",&t);
  9. for(i=0;i<t;i++)
  10. {
  11. scanf("%s",a);
  12. r1=a[0]-'a';
  13. c1=a[1]-'1';
  14. int sum=0;
  15. for(j=0;j<8;j++)
  16. {
  17. r2=r[j]+r1;
  18. c2=c[j]+c1;
  19.  
  20. if(r2>=0 && r2<8 && c2>=0 && c2<8)
  21. sum++;
  22. }
  23. printf("%d\n",sum);
  24.  
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement