题目链接:

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. Android proguard (混淆)

    混淆(Proguard)用法 最近项目中遇到一些混淆相关的问题,由于之前对proguard了解不多,所以每次都是面向Stackoverflow的编程.copy别人的答案内心还可以接受,但是copy了之 ...

  2. nginx配置防盗链

    location ~* \.(gif|jpg|swf|flv|mp3|mp4|zip|rar)$ { root /home/soft; valid_referers *.qinyj.top downl ...

  3. Matlab绘图基础——绘制三维曲线

    %% 绘制三维曲线 %plot3函数,其中每一组x,y,z组成一组曲线的坐标参数,选项的定义和plot函数相同. %1.当x,y,z是同维向量时,则x,y,z 对应元素构成一条三维曲线. x0 = 0 ...

  4. Android开发之eclipse 快捷键

    转自:<Android开发之eclipse 快捷键>http://www.cnblogs.com/aimeng/archive/2012/08/07/2626909.html Ctrl+1 ...

  5. 查看Linux内核版本之lsb_release

    lsb_release命令LSB是Linux Standard Base的缩写,lsb_release命令用来显示LSB和特定版本的相关信息,可通过yum -y install redhat-lsb命 ...

  6. cocos对lua代码加密

    1.0 cocos luacompile 用法 我用的普通的cocos2d lua,没用quick,quick好像可以对整个资源包括图像和音频都加密,打包成zip.但我没用quick.看了下luaco ...

  7. C#,一份超简单的数据库帮助类,SqlHelp

    简单,实用,留存. using System; using System.Collections.Generic; using System.Configuration; using System.D ...

  8. Sublime Text3下使用Python,REPL的安装与快捷键设置方法

    前提条件:连接外网   1.安装管理插件(CTRL+SHIFT+P),找到Package Control:install package一项,回车后继续选择SublimeREPL插件,进行安装:   ...

  9. C程序第二次作业

    2-1删除字符串中数字字符 1.设计思路 (1)主要描述题目算法 第一步:遍历指针s所指的s数组. 第二步:如果 * (s+i)在0至9之间的话,则跳过此 * (s+i). 第三步:如果* (s+i) ...

  10. 201621123031 《Java程序设计》第10周学习总结

    作业10-异常 1.本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 1.捕捉异常 Java中的异常捕获结构由try.catch和finally三个部分组成.其中try语句 ...