参考:https://blog.csdn.net/yzl_rex/article/details/7600906

https://blog.csdn.net/acm_JL/article/details/50200355

https://blog.csdn.net/qq_35040828/article/details/71123521

https://zhidao.baidu.com/question/49762862.html

 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=;
char old[N][N],news[N][N];//old存旧数组,news存新数组
int dir[][]={{-,,,},{,,,-}};//周围四个格
int r,l,n;
int lawful(int x,int y)//判断是否超出边界
{
if (x>=&&x<r&&y>=&&y<l)
{
return ;
}
else
{
return ;
}
}
char change(int x,int y)//依据规则改变
{
for (int i=;i<;i++)
{
int xx=x+dir[][i];
int yy=y+dir[][i];
if (lawful(xx,yy))
{
if (old[xx][yy]=='R'&&old[x][y]=='S')
{
return 'R';
}
else if (old[xx][yy]=='S'&&old[x][y]=='P')
{
return 'S';
}
else if (old[xx][yy]=='P'&&old[x][y]=='R')
{
return 'P';
}
}
}
return old[x][y];
}
int main()
{
int t;
// freopen("bin.txt","r",stdin);
while (cin>>t)
{
while (t--)
{
cin>>r>>l>>n;
memset(old,,sizeof(old));
memset(news,,sizeof(news));
for (int i=;i<r;i++)
{
for (int j=;j<l;j++)
{
cin>>old[i][j];
}
}
for (int i=;i<n;i++)
{
for (int j=;j<r;j++)
{
for (int k=;k<l;k++)
{
news[j][k]=change(j,k);//更新news
}
}
memcpy(old,news,sizeof(news));
}
for (int i=;i<r;i++)
{
for (int j=;j<l;j++)
{
cout<<old[i][j];
}
cout<<endl;
}
cout<<endl;
}
} return ;
}

poj_2339的更多相关文章

随机推荐

  1. 初次接触《C++程序设计原理与实践》一书

    前两天读书日,买了些书回来看.__Bjarne Stroustrup__的<C++程序设计原理与实践>便是其中一本.其实也没看完,只看了第0章-致读者,大师不愧是大师,只看了一章就让心生共 ...

  2. 使用 Android 客户端向 Ruby on rails 构建的 Web Application 提交 HTTP GET 和 HTTP POST 请求

    最近想弄个能访问 Internet 的 Android 应用,因为求快所以用了 Ruby on Rails 来提供 HTTP 资源.这方面的资料还是比较少的,所以把尝试的过程记录下来. 1 使用 Ru ...

  3. 从零开始Vue项目实战(三)-项目结构

    目录结构 ├── README.md 项目介绍 ├── index.html 入口页面 ├── build 构建脚本目录 │ ├── build-server.js 运行本地构建服务器,可以访问构建后 ...

  4. Linux 进程状态标识 Process State Definition

    From : http://www.linfo.org/process_state.html 译者:李秋豪 进程状态标识是指在进程描述符中状态位的值. 进程,也可被称为任务,是指一个程序运行的实例. ...

  5. 如何使用MiniProfiler(附最新版MiniProfiler使用心得)

    MiniProfiler这个工具早就久仰大名,不过之前一直没有动力去用,正好最近手上有个ASP.NET MVC的项目,正好拿来试试手,下面是使用最新的4.0.138版本的心得体会以及踩到一些小坑的解决 ...

  6. Android学习笔记_26_多媒体之拍照

    一.配置文件: 需要引入摄像头权限,sdcard读写权限. <?xml version="1.0" encoding="utf-8"?> <m ...

  7. 发布Android程序

    这个选项的意思是说,要使用.NET 2.0的完整版本,而非其子集. 下午发布Apk,一直报错,解决好了,忘记选这个了,以前都记得,明天再去公司发布去

  8. python的格式化输出(format,%)

    皇城PK Python中格式化字符串目前有两种阵营:%和format,我们应该选择哪种呢? 自从Python2.6引入了format这个格式化字符串的方法之后,我认为%还是format这根本就不算个问 ...

  9. java 后台返回文件流到浏览器

    package com.springbootblog.controller; import io.swagger.annotations.ApiImplicitParam;import io.swag ...

  10. TinyMCE(富文本编辑器)在Asp.Net中的使用方法

    TinyMCE(富文本编辑器)在Asp.Net中的使用方法   转至:http://www.cnblogs.com/freeliver54/archive/2013/02/28/2936506.htm ...