http://poj.org/problem?id=2965
1 #include<stdio.h> 2 #include<string.h> 3 int arr[4][4];//存储状态 4 int main() 5 { 6 int i,j; 7 char ch; 8 memset(arr[0],0,sizeof(arr[0])); 9 for (i = 0; i < 4; i ++) 10 { 11 for (j = 0; j < 4; j ++) 12 { 13 ch = getchar(); 14 if(ch=='+') 15 { 16 arr[i][j] = !arr[i][j]; 17 for (int k = 0; k < 4; k ++) 18 { 19 arr[i][k] = !arr[i][k]; 20 arr[k][j] = !arr[k][j]; 21 } 22 } 23 } 24 getchar(); 25 } 26 int ans = 0; 27 for (i = 0; i < 4; i ++) 28 { 29 for (j = 0 ; j < 4; j ++) 30 { 31 if(arr[i][j])//状态为1的为需要转换的位置 32 ans++; 33 } 34 } 35 printf("%d ",ans); 36 for (i = 0; i < 4; i ++) 37 { 38 for (j = 0; j < 4; j ++) 39 { 40 if(arr[i][j]) 41 printf("%d %d ",i+1,j+1); 42 } 43 } 44 return 0; 45 }