水题一道,两个条件 1:不能所有的都是1 2:不能有0相邻 思路很简单,每输入一个数,扫描它左边和上边的点,如果出现两个相等的0,则输出no 比较悲剧的是,写的时候竟然把行和列弄反了,wa了,郁闷 #include <stdio.h> int main(void) { int n,m,row,column; int a[12][12]; while (scanf("%d %d",&n,&m) != EOF && n &&m) { int flag = 0,count=0; /*标记*/ for (column = 0;column <=m;column++) a[0][column] = 1; for (row = 0;row<=n ;row++) a[row][0] = 1; for (row=1;row<=n;row++) for (column=1;column<=m;column++) { scanf("%d",&a[row][column]); if (!a[row][column]) count++; if ( (a[row][column]+a[row][column-1] == 0 ) || (a[row][column]+a[row-1][column]==0) ) flag = 1; } if (count&&!flag) printf("Yes/n"); else printf("No/n"); } return 0; }