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: ...
随机推荐
- Angular组件——父子组件通讯
Angular组件间通讯 组件树,1号是根组件AppComponent. 组件之间松耦合,组件之间知道的越少越好. 组件4里面点击按钮,触发组件5的初始化逻辑. 传统做法:在按钮4的点击事件里调用组件 ...
- poj-1005-l tanink i need a houseboat
Description Fred Mapper is considering purchasing some land in Louisiana to build his house on. In t ...
- 搭建hadoop伪分布式环境
伪分布式就是只有一台机器,既是namenode又是datanode.一台阿里云服务器(centos)即可完成. Java环境 首先需要安装Java环境,下载jdk的安装包,解压到/usr/java/, ...
- 大数据 --> Kafka集群搭建
Kafka集群搭建 下面是以三台机器搭建为例,(扩展到4台以上一样,修改下配置文件即可) 1.下载kafka http://apache.fayea.com/kafka/0.9.0.1/ ,拷贝到三台 ...
- Jquery判断checkbox是否被选中
jQuery中: $("input[type='checkbox']").is(':checked') 返回true或false 1.attr()方法 设置或者返回备选元素的值 ...
- springboot集成mybatisplus
介绍: Mybatis-Plus(简称MP)是一个 Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变,为简化开发.提高效率而生.(摘自mybatis-plus官网)Mybati ...
- 编写简单的辅助脚本来在 Google 表格上记账
我的第二份工作入职在即,而这一次则真的是完全跑到了一个陌生的城市了.租房,购置相关用品,还尚未工作钱就花掉一堆.尽管我个人之前一直都没有过记账的习惯,但为了让自己能够搞清楚自己的钱都花在哪里了,于是还 ...
- 网络1712--c语言字符数组作业总结..
---恢复内容开始--- 作业亮点 1.总体情况 1.大部分同学利用了流程图后,对于思路的理解有了提升. 2.很多同学在总结方面写的很不错,能够罗列问题贴出解决问题,我们能够看到你们的进步 2.作业发 ...
- 冲刺NO.9
Alpha冲刺第九天 站立式会议 项目进展 项目已完成模块的模块测试工作开始进行.如学生基本信息模块和学生信用信息模块. 问题困难 框架的掌握存在一定的问题,导致项目的执行速度变慢.其他课程的作业占据 ...
- iOS开发-简单的循环结构分析
1.while循环 while (循环条件) { 循环体: } // 1.定义循环变量 ; // 2.循环条件 ) { // 3.循环体 printf("%d\n" ...