zoukankan      html  css  js  c++  java
  • 模拟 POJ 2993 Emag eht htiw Em Pleh

    题目地址:http://poj.org/problem?id=2993

      1 /*
      2     题意:与POJ2996完全相反
      3     模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出字母,否则输出'.'或':'。
      4     注意:棋盘的行的顺序是从下到上递增的
      5 */
      6 #include <cstdio>
      7 #include <iostream>
      8 #include <algorithm>
      9 #include <cstring>
     10 #include <cmath>
     11 #include <string>
     12 #include <map>
     13 #include <queue>
     14 #include <vector>
     15 using namespace std;
     16 
     17 const int MAXN = 1e3 + 10;
     18 const int INF = 0x3f3f3f3f;
     19 int used[MAXN][MAXN];
     20 char a[MAXN][MAXN];
     21 map<char, int> m;
     22 string s1,s2;
     23 
     24 void print(int tw, int tb)
     25 {
     26     bool flag = false;
     27     for (int i=1; i<=8; ++i)
     28     {
     29         cout << "+---+---+---+---+---+---+---+---+" << endl;
     30         cout << "|";
     31         flag = !flag;
     32         for (int j=1; j<=8; ++j)
     33         {
     34             (flag) ? cout << "." : cout << ":";
     35             if (!used[i][j])    (flag) ? cout << "." : cout << ":";
     36             else
     37             {
     38                 cout << a[i][j];
     39             }
     40             (flag) ? cout << "." : cout << ":";
     41             flag = !flag;
     42             cout << "|";
     43         }
     44         cout << endl;
     45     }
     46 
     47     cout << "+---+---+---+---+---+---+---+---+" << endl;
     48 }
     49 
     50 void work(void)
     51 {
     52     int tw = 0, tb = 0;
     53     for (int i=7; s1[i]!=''; ++i)        //White
     54     {
     55         if (s1[i] == ',')    continue;
     56         if (s1[i]<='S' && s1[i] >= 'B')
     57         {
     58             a[9-(s1[i+2]-'0')][m[s1[i+1]]] = s1[i];
     59             used[9-(s1[i+2]-'0')][m[s1[i+1]]] = 1;
     60             i += 3;
     61         }
     62         if (s1[i]<='s' && s1[i]>='a')
     63         {
     64             a[9-(s1[i+1]-'0')][m[s1[i]]] = 'P';
     65             used[9-(s1[i+1]-'0')][m[s1[i]]] = 1;
     66             i += 2;
     67         }
     68         if (i >= s1.size ())    break;
     69     }
     70     for (int i=7; s2[i]!=''; ++i)        //Black
     71     {
     72         if (s2[i] == ',')    continue;
     73         if (s2[i]<='S' && s2[i] >= 'B')
     74         {
     75             a[9-(s2[i+2]-'0')][m[s2[i+1]]] = s2[i] - 'A' + 'a';
     76             used[9-(s2[i+2]-'0')][m[s2[i+1]]] = 1;
     77             i += 3;
     78         }
     79         if (s2[i]<='s' && s2[i]>='a')
     80         {
     81             a[9-(s2[i+1]-'0')][m[s2[i]]] = 'p';
     82             used[9-(s2[i+1]-'0')][m[s2[i]]] = 1;
     83             i += 2;
     84         }
     85         if (i >= s2.size ())    break;
     86     }
     87 
     88     print (tw, tb);
     89 }
     90 
     91 int main(void)        //POJ 2993 Emag eht htiw Em Pleh
     92 {
     93     //freopen ("J.in", "r", stdin);
     94 
     95     char ch = 'a';
     96     for (int i=1; i<=8; ++i)
     97     {
     98         m[ch++] = i;
     99     }
    100 
    101     getline (cin, s1);
    102     getline (cin, s2);
    103     memset (used, 0, sizeof (used));
    104     work ();
    105     
    106     return 0;
    107 }
    108 
    109 /*
    110 +---+---+---+---+---+---+---+---+
    111 */
    112 
    113 /*
    114 +---+---+---+---+---+---+---+---+
    115 |.r.|:::|.b.|:q:|.k.|:::|.n.|:r:|
    116 +---+---+---+---+---+---+---+---+
    117 |:p:|.p.|:p:|.p.|:p:|.p.|:::|.p.|
    118 +---+---+---+---+---+---+---+---+
    119 |...|:::|.n.|:::|...|:::|...|:p:|
    120 +---+---+---+---+---+---+---+---+
    121 |:::|...|:::|...|:::|...|:::|...|
    122 +---+---+---+---+---+---+---+---+
    123 |...|:::|...|:::|.P.|:::|...|:::|
    124 +---+---+---+---+---+---+---+---+
    125 |:P:|...|:::|...|:::|...|:::|...|
    126 +---+---+---+---+---+---+---+---+
    127 |.P.|:::|.P.|:P:|...|:P:|.P.|:P:|
    128 +---+---+---+---+---+---+---+---+
    129 |:R:|.N.|:B:|.Q.|:K:|.B.|:::|.R.|
    130 +---+---+---+---+---+---+---+---+
    131 */
    编译人生,运行世界!
  • 相关阅读:
    根本解决:由于没有远程桌面授权服务器可以提供许可证,远程会话被中断。
    通过SQLServer的数据库邮件来发送邮件
    SQLFullbackup
    vs2015 iis express启动不了及安装DotNetCore.1.0.0-VS2015Tools.Preview2失败的解决方法
    Django1.7+JQuery+Ajax集成小例子
    编译安装带ssl 模块指定版本Python
    细说IIS异常日志 — 你必须知道的功能
    7 MySQL存储过程和函数
    6 MySQL视图
    5 MySQL索引
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4372548.html
Copyright © 2011-2022 走看看