Advertisement
skashminzim

Boring chess

Oct 5th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int x,y,t,i;
  5.     scanf("%d",&t);
  6.     for(i=1;i<=t;i++)
  7.     {
  8.     scanf("%d%d",&x,&y);
  9.     int c=0;
  10.     if( x-1>0 && y+2>0 && x-1<9 && y+2<9)
  11.         c++;
  12.     if(x+1>0 && y+2>0 && x+1<9 && y+2<9)
  13.         c++;
  14.     if(x-2>0 && y+1>0 && x-2<9 && y+1<9)
  15.         c++;
  16.     if(x+2>0 && y+1>0 && x+2<9 && y+1<9)
  17.         c++;
  18.     if(x-2>0 && y-1>0 && x-2<9 && y-1<9)
  19.         c++;
  20.     if(x+2>0 && y-1>0 && x+2<9 && y-1<9)
  21.         c++;
  22.      if(x-1>0 && y-2>0 && x-1<9 && y-2<9)
  23.         c++;
  24.       if(x+1>0 && y-2>0 && x+1<9 && y-2<9)
  25.         c++;
  26.       printf("Case %d: %d\n",i,c);
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement