咋一看很简单,一边遍历一边搞就好,但其实不是想象中的那么简单。 #include<stdio.h> #define N 9 #define M 8 int main(void) { int a[M][N]; int i,j; int seed = 1; for(i=0; i<M; i++) for(j=0; j<N; j++) a[i][j] = seed++; a[1][3] = 0; a[6][6] = 0; int row[M] = {0}; int col[N] = {0}; for(i=0; i<M; i++) { for(j=0; j<N; j++) { if(a[i][j] == 0) { row[i] = 1; col[j] = 1; } } } for(i=0; i<M; i++) { for(j=0; j<N; j++) { if(row[i]==1 || col[j]==1) a[i][j] = 0; } } return 0; }