Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- int main()
- {
- int i,j,f,t,n,tt,x,y,top2,k,q,m,r,c;
- char map[8][8];
- while(scanf("%d %d %d",&k,&q,&m)==3)
- {
- if(k==q){
- printf("Illegal state\n");
- continue;
- }
- for(i=0;i<8;i++)
- for(j=0;j<8;j++)
- map[i][j]='e';
- r=k/8;
- c=k-r*8;
- map[r][c]='k';
- if(r+1<8)
- map[r+1][c]='o';
- if(r-1>=0)
- map[r-1][c]='o';
- if(c+1<8)
- map[r][c+1]='o';
- if(c-1>=0)
- map[r][c-1]='o';
- r=q/8;
- c=q-r*8;
- map[r][c]='q';
- for(i=r;i<8&&map[i][c]!='k';i++)
- {
- if(map[i][c]=='o')
- map[i][c]='g';
- else
- map[i][c]='x';
- }
- for(i=r;i>=0&&map[i][c]!='k';i--)
- {
- if(map[i][c]=='o')
- map[i][c]='g';
- else
- map[i][c]='x';
- }
- for(i=c;i<8&&map[r][i]!='k';i++)
- {
- if(map[r][i]=='o')
- map[r][i]='g';
- else
- map[r][i]='x';
- }
- for(i=c;i>=0&&map[r][i]!='k';i--)
- {
- if(map[r][i]=='o')
- map[r][i]='g';
- else
- map[r][i]='x';
- }
- r=q/8;
- c=q-r*8;
- map[r][c]='q';
- y=m/8;
- x=m-y*8;
- if(map[y][x]=='g')
- printf("Move not allowed\n");
- else if(map[y][x]!='x')
- printf("Illegal move\n");
- else if(map[y][x]=='x')
- {
- if(m==49&&k==56||m==14&&k==7||m==9&&k==0||m==54&&k==63)
- printf("Stop\n");
- else
- printf("Continue\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement