mhdew

Timus 1197

Mar 23rd, 2018
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int i, n;
  6. int a, ans;
  7. char b;
  8.  
  9. scanf("%d", &n);
  10. for(i=1;i<=n;i++){
  11. getchar();
  12. scanf("%c%d", &b,&a);
  13.  
  14. if(b=='a' || b=='h'){
  15. if(a==1 || a==8)
  16. ans=2;
  17. else if(a==2 || a==7)
  18. ans=3;
  19. else if(a>=3 && a<=6)
  20. ans=4;
  21. }
  22. else if(b=='b' || b=='g'){
  23. if(a==1 || a==8)
  24. ans=3;
  25. else if(a==2 || a==7)
  26. ans=4;
  27. else if(a>=3 && a<=6)
  28. ans=6;
  29. }
  30. else if(b>='c' && b<='f'){
  31. if(a==1 || a==8)
  32. ans=4;
  33. else if(a==2 || a==7)
  34. ans=4;
  35. else if(a>=3 && a<=6)
  36. ans=8;
  37. }
  38. printf("%d\n", ans);
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment