题目链接:

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 获取文件内所有文件名

    package com.xinwen.user.controller; import java.io.File;import java.util.ArrayList;import java.util. ...

  2. 移动端常用的meta标签,媒体查询以及一些样式设置《转载收藏》

    <meta name="screen-orientation" content="portrait"> <meta name="fu ...

  3. spring boot高性能实现二维码扫码登录(上)——单服务器版

    前言 目前网页的主流登录方式是通过手机扫码二维码登录.我看了网上很多关于扫码登录博客后,发现基本思路大致是:打开网页,生成uuid,然后长连接请求后端并等待登录认证相应结果,而后端每个几百毫秒会循环查 ...

  4. 笔记:Hibernate 二级缓存

    Hibernate 包括二个级别的缓存,默认的总是启用Session级别的一级缓存,可选的 SessionFactory 级别的二级缓存,Session级别的一级缓存,但应用保存持久化实体.修改持久化 ...

  5. 你不知道的Google控制台

    1.页面可编辑 document.body.contentEditable=true 2.console.table() 3.console.dir 4.clear() 清空控制台 5.sources ...

  6. 本地不安装oracle,PLsql远程连接

    Oracle的Instant client工具包可以很好地解决本地不安装oracle,PLsql远程连接. 1.首先到Oracle网站下载Instant Client : http://www.ora ...

  7. 巨人大哥谈Java中的Synchronized关键字用法

    巨人大哥谈Java中的Synchronized关键字用法 认识synchronized 对于写多线程程序的人来说,经常碰到的就是并发问题,对于容易出现并发问题的地方价格synchronized基本上就 ...

  8. Java字符编码浅析

    Java基本类型占用的字节数:1字节: byte , boolean2字节: short , char4字节: int , float8字节: long , double注:1字节(byte)=8位( ...

  9. 『开源重编译』System.Data.SQLite.dll 自适应 x86 x64 AnyCPU 重编译

    背景: > System.Data.SQLite.dll 程序集 不能良好的支持 AngCPU 格式 System.Data.SQLite.dll 在 适应 x86 和 x64 有三个方案: & ...

  10. 2018.3.29 DIV位置调整代码

    <!DOCTYPE html><html>    <head>        <meta charset="UTF-8">      ...