// 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;
};

最新文章

  1. Git 版本库添加空目录方法
  2. 【leetcode】Merge Two Sorted Lists
  3. js给定时器调用传递参数
  4. openstack 基本配置
  5. ubuntukylin提取root权限及mongoDB部署
  6. Android Service 系统服务
  7. 这几天有django和python做了一个多用户博客系统(可选择模板)
  8. 手机下的ev.pageX无效
  9. 学习Robot Framework必须掌握的库—-BuiltIn库
  10. seq语句随笔
  11. ArcGIS制图技巧系列(2)地形渲染
  12. Oracle12c中数据泵新特性之功能增强(expdp, impdp)
  13. MySQL 笔记整理(19) --为什么我只查一行的语句,也执行这么慢?
  14. Uncaught DOMException: Failed to construct &#39;WebSocket&#39;: The URL
  15. Null component Catalina
  16. 与Recommender System相关的会议及期刊
  17. xshell下mysql数据库只导出表结构不导出数据
  18. maven依赖jar导出消失问题
  19. 大数据java基础day01
  20. mongodb基础环境搭建

热门文章

  1. SQl性能优化1
  2. 调用Outlook发送邮件
  3. ckeditor编辑的使用方法
  4. [LeetCode] Maximum Product Subarray 连续数列最大积
  5. Java发送邮件----自己封装的方法
  6. java模拟一次简单的sql注入
  7. DB2数据库用 With语句分隔字符
  8. Scala之Future超时
  9. rownum详解
  10. linux调整缓存写入磁盘的时间,减少磁盘爆掉的可能性