题目链接:

https://vjudge.net/problem/POJ-2993

题目大意:

输入和输出和这里相反。

思路:

模拟题,没啥算法,直接模拟,不过为了代码精简,还是花了一点心思的

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<sstream>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + ;
const int INF = << ;
int dir[][] = {,,,,-,,,-};
int T, n, m, x;
char Map[][];
void init()//将棋盘初始化
{
for(int i = ; i < ; i++)
{
if(i & )
{
for(int j = ; j < ; j ++)
{
if(j % == )Map[i][j] = '|';
else if(((i / ) & ) == ((j / ) & ))Map[i][j] = '.';//这波操作好好理解,为了代码精简想出来的
else Map[i][j] = ':';
}
}
else for(int j = ; j < ; j++)
if(j % == )Map[i][j] = '+';
else Map[i][j] = '-';
}
}
void output()//输出棋盘
{
for(int i = ; i < ; i++)
{
for(int j = ; j < ; j++)
{
cout<<Map[i][j];
}
cout<<endl;
}
}
void solve(int d)
//x表示偏移量,白色的时候调用solve(0),黑色调用solve(32)
//表示每个大写字母加上32变成小写字母
{
string s;
getline(cin, s);
for(int i = ; i < s.size(); i++)
{
if(s[i] == ':' || s[i] == ',')s[i] = ' ';
}
stringstream ss(s);
string s1;
while(ss >> s1)
{
int x, y;
if(s1.size() == )
{
x = s1[] - '';
y = s1[] - 'a';
x = - x * ;//将行数转化成具体在数组里面的行数
y = y * + ;//将列数转化成具体的列数
Map[x][y] = 'P' + d;//这里加上d
}
else if(s1.size() == )
{
x = s1[] - '';
y = s1[] - 'a';
x = - x * ;
y = y * + ;
Map[x][y] = s1[] + d;
}
}
}
int main()
{
init();
solve();
solve('a' - 'A');
output();
return ;
}

POJ-2993 Emag eht htiw Em Pleh---棋盘模拟的更多相关文章

  1. POJ 2993 Emag eht htiw Em Pleh【模拟画棋盘】

    链接: http://poj.org/problem?id=2993 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...

  2. poj 2993 Emag eht htiw Em Pleh(模拟)

    题目:http://poj.org/problem?id=2993 题意:和2996反着 #include <iostream> #include<cstdio> #inclu ...

  3. 模拟 POJ 2993 Emag eht htiw Em Pleh

    题目地址:http://poj.org/problem?id=2993 /* 题意:与POJ2996完全相反 模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出 ...

  4. Poj 2993 Emag eht htiw Em Pleh

    1.Link: http://poj.org/problem?id=2993 2.Content: Emag eht htiw Em Pleh Time Limit: 1000MS   Memory ...

  5. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

  6. POJ 2993:Emag eht htiw Em Pleh

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64 ...

  7. Emag eht htiw Em Pleh 分类: POJ 2015-06-29 18:54 10人阅读 评论(0) 收藏

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2937   Accepted: ...

  8. Emag eht htiw Em Pleh

    Emag eht htiw Em Pleh This problem is a reverse case of the problem 2996. You are given the output o ...

  9. 模拟 + 打表 --- Emag eht htiw Em Pleh

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2578   Accepted: ...

  10. Emag eht htiw Em Pleh(imitate)

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2901   Accepted:  ...

随机推荐

  1. java报错排解

    1.eclipse新安装第一次启动报错: Javawas started but returned exit code=13-- 这是由于JDK和eclipse和电脑的位数不一致所致,要么都为32位, ...

  2. thinkphp3.2-更改控制器名后找不到相应的表?报1146的错

    用tp在做着自己的小系统的时候,明明在刚才还是能好好地查到表的,在Service用了'D'方法连自己数据库的表,只是更改了自己的控制器名,却报错了... 我就纳闷了,虽然我的控制器和Service用的 ...

  3. [Luogu 1402] 酒店之王

    题目 Description XX酒店的老板想成为酒店之王,本着这种希望,第一步要将酒店变得人性化.由于很多来住店的旅客有自己喜好的房间色调.阳光等,也有自己所爱的菜,但是该酒店只有p间房间,一天只有 ...

  4. jQuery中ajax方法无法执行回调函数问题

    最近遇到一个问题,发现使用jquery的ajax方法时,回调方法无法执行,而使用$.load()方法时却能正确返回数据.经过长时间调试最终发现是自己粗心大意,原来后台返回的是json数据,而返回的数据 ...

  5. spring boot — InputStream

    @Componentpublic class TextFileDownloadView extends AbstractFileDownloadView { @Override protected I ...

  6. 论文阅读——Visual inertial odometry using coupled nonlinear optimization

    简介:论文提出一种新的视觉里程计算法,其直接利用带噪声的IMU数据和视觉特征位置来优化相机位姿.不同于对IMU和视觉数据运行分离的滤波器,这种算法将它们纳入联合的非线性优化框架中.视觉特征的透视重投影 ...

  7. JavaScript(第三十二天)【Ajax】

    2005年Jesse James Garrett发表了一篇文章,标题为:"Ajax:A new Approach to Web Applications".他在这篇文章里介绍了一种 ...

  8. JavaScript(第十九天)【DOM进阶】

    学习要点: 1.DOM类型 2.DOM扩展 3.DOM操作内容 DOM自身存在很多类型,在DOM基础课程中大部分都有所接触,比如Element类型:表示的是元素节点,再比如Text类型:表示的是文本节 ...

  9. 敏捷开发冲刺--day3

    1 团队介绍 团队组成: PM:齐爽爽(258) 小组成员:马帅(248),何健(267),蔡凯峰(285)  Git链接:https://github.com/WHUSE2017/C-team 2 ...

  10. electron-vue工程创建

    没有vue创建经验请移步至 vue下载与安装 使用vue创建electron-vue工程 vue init simulatedgreg/electron-vue my-project 安装elemen ...