1 #include<stdio.h> 2 int main() 3 { 4 int desk[101][101]={0}; 5 int i,j,k,l,m,n; 6 int hx,hy; 7 scanf("%d%d",&m,&n); 8 scanf("%d%d",&hx,&hy); 9 desk[hx][hy]=-1; 10 if(hx+2<=m) //优化算法什么的都去死吧 11 if(hy+1<=n) desk[hx+2][hy+1]=-1; 12 if(hy-1>=0) desk[hx+2][hy-1]=-1; 13 if(hx+1<=m) 14 if(hy+2<=n) desk[hx+1][hy+2]=-1; 15 if(hy-2>=0) desk[hx+1][hy-2]=-1; 16 if(hx-1>=0) //复制粘贴大法好 17 if(hy+2<=n) desk[hx-1][hy+2]=-1; 18 if(hy-2>=0) desk[hx-1][hy-2]=-1; 19 if(hx-2>=0) 20 if(hy+1<=n) desk[hx-2][hy+1]=-1; 21 if(hy-1>=0) desk[hx-2][hy-1]=-1; 22 for(i=0;i<=m;i++) 23 { 24 for(j=0;j<=n;j++) 25 desk[i][j]==0?printf("#"):printf("X"); 26 printf("\n"); 27 } 28 }
时间: 2024-11-09 05:12:14