题目: http://acm.hdu.edu.cn/showproblem.php?pid=2565
这个题很简单 但是很容易错,写来给自己一个警示把
首先在最后一个x后面没有空格,然后就是那个换行一直换就好, 我一开始是空格 后来是那个换行出问题,,纠结了半天,,,,
#include <stdio.h> #include <string.h> int a[80][80]; int main() { /** freopen("1.txt","w",stdout);*/ int t; int x1,y1,x2,y2,i,j; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); int n,t1 = 0; scanf("%d",&n); x1 = 1,y1 = 1,x2 = 1,y2 = n; for(i = 1; i <= n; i++) { int t1 = 0; a[x1][y1] = 1; a[x2][y2] = 1; if(x1 == x2 && y1 == y2) t1 = 1; for(j = 1; j <= n; j++) { if(a[i][j] == 1) printf("X"),t1++; else printf(" "); if(t1 == 2) break; } printf(" "); x1++,y1++; x2++,y2--; } printf(" "); } return 0; }