POJ 2965(枚举)

版权声明:听说这里让写版权声明~~~ https://blog.csdn.net/m0_37691414/article/details/82083224
#include<iostream>
using namespace std;
int map[5][5];
void flip(int x, int y){
	for(int i = 1; i <= 4; ++i){
		map[x][i]++;
		if(i != x) map[i][y]++;
	}
}
int main(){
	char c;
	for(int i = 1; i <= 4; ++i)
		for(int j = 1; j <= 4; ++j){
			cin >> c;
			if(c == '+') flip(i, j);
		}
	int step = 0;
	for(int i = 1; i <= 4; ++i)
		for(int j = 1; j <= 4; ++j)
			if(map[i][j] & 1)	step++;
	printf("%d\n", step);
	for(int i = 0; i <= 4; ++i)
		for(int j = 1; j <= 4; ++j)
			if(map[i][j] % 2)	printf("%d %d\n", i, j);
		return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_37691414/article/details/82083224