// ConsoleApplication10.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
using namespace std;
class Flip {
public:
vector<vector<int> > flipChess(vector<vector<int> > A, vector<vector<int> > f) {
for (int i = 0;i < f.size();i++)
{
int row = f[i][0];
int col = f[i][1];
if (row >= 0 && row < 4 && col - 1 >= 0 && col - 1 < 4)
{
if (A[row][col - 1] == 0) A[row][col - 1] = 1;
else A[row][col - 1] = 0;
}
if (row-2 >= 0 && row-2 < 4 && col - 1 >= 0 && col - 1 < 4)
{
if (A[row-2][col - 1] == 0) A[row-2][col - 1] = 1;
else A[row-2][col - 1] = 0;
}
if (row-1 >= 0 && row-1 < 4 && col >= 0 && col < 4)
{
if (A[row-1][col ] == 0) A[row-1][col ] = 1;
else A[row-1][col ] = 0;
}
if (row-1 >= 0 && row-1 < 4 && col - 2 >= 0 && col - 2 < 4)
{
if (A[row-1][col - 2] == 0) A[row-1][col - 2] = 1;
else A[row-1][col - 2] = 0;
}
}
return A;
}
};
int main()
{
Flip fl;
vector<int> A1 = { 0,0,1,1 };
vector<int> A2 = { 1,0,1,0 };
vector<int> A3 = { 0,1,1,0 };
vector<int> A4 = { 0,0,1,0 };
vector<vector<int> > A;
A.push_back(A1);
A.push_back(A2);
A.push_back(A3);
A.push_back(A4);
vector<int> f1 = { 2,2 };
vector<int> f2 = { 3,3 };
vector<int> f3 = { 4,4 };
vector<vector<int> > f;
f.push_back(f1);
f.push_back(f2);
f.push_back(f3);
vector<vector<int> > re= fl.flipChess(A, f);
return 0;
};