POJ-2993 Emag eht htiw Em Pleh---棋盘模拟
题目链接:
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---棋盘模拟的更多相关文章
- 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 ...
- poj 2993 Emag eht htiw Em Pleh(模拟)
题目:http://poj.org/problem?id=2993 题意:和2996反着 #include <iostream> #include<cstdio> #inclu ...
- 模拟 POJ 2993 Emag eht htiw Em Pleh
题目地址:http://poj.org/problem?id=2993 /* 题意:与POJ2996完全相反 模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出 ...
- 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 ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- POJ 2993:Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64 ...
- 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: ...
- 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 ...
- 模拟 + 打表 --- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2578 Accepted: ...
- Emag eht htiw Em Pleh(imitate)
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2901 Accepted: ...
随机推荐
- Mysql使用规范文档 20180223版
强制:不允许在跳板机上/生产服务器上手工连接,查询或更改线上数据 强制:所有上线脚本必须先在测试环境执行,验证通过以后方可在生产环境执行. 强制:上线脚本的编码格式统一为UTF-8 强制:访问数据库需 ...
- ASCII代码
ASCII(American Standard Code for Information Interchange,美国标准信息交换代码)是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧 ...
- Spark Kudu 结合
Kudu的背景 Hadoop中有很多组件,为了实现复杂的功能通常都是使用混合架构, Hbase:实现快速插入和修改,对大量的小规模查询也很迅速 HDFS/Parquet + Impala/Hive:对 ...
- 【Bootstrap】bootstrap-datetimepicker日期时间插件
[bootstrap-datetimepicker] datetimepicker是一个比较方便的日期时间插件.有了这个之后,我们可以在类似于表单的地方提供一个友好的日期(时间)输入功能.官方文档:[ ...
- python+pycahrm+windows环境准备
python安装教程和Pycharm安装详细教程 首先我们来安装python 1.首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downloads/),进 ...
- UI线程异常处理方法
当应用程序启动,创建了一个叫“main”的线程,用于管理UI相关,又叫UI线程.其他线程叫工作线程(Work Thread). Single Thread Model 一个组件的创建并不会新建一个线程 ...
- 设计模式之迭代器模式详解(foreach的精髓)
作者:zuoxiaolong8810(左潇龙),转载请注明出处,特别说明:本博文来自博主原博客,为保证新博客中博文的完整性,特复制到此留存,如需转载请注明新博客地址即可. 各位好,很久没以LZ的身份和 ...
- Alpha第三天
Alpha第三天 听说 031502543 周龙荣(队长) 031502615 李家鹏 031502632 伍晨薇 031502637 张柽 031502639 郑秦 1.前言 任务分配是VV.ZQ. ...
- 201621123050 《Java程序设计》第4周学习总结
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 继承.抽象.多态 1.2 尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需要出现过多的字. 1.3 可选:使用常规方法 ...
- 静态关键字static用法。
static的特点:1,static是一个修饰符,用于修饰成员.2,static修饰的成员被所有的对象所共享.3,static优先于对象存在,因为static的成员随着类的加载就已经存在了. 4,st ...