zoukankan      html  css  js  c++  java
  • poj 2993

    今天心情不好  找个代码  看着不错  直接提交

    #include<iostream>
    #include<cstring>
    using namespace std;
    const int Max = 100;
    
     
    
    char map[17][34] = { "+---+---+---+---+---+---+---+---+",
                         "|...|:::|...|:::|...|:::|...|:::|",
                         "+---+---+---+---+---+---+---+---+",
                         "|:::|...|:::|...|:::|...|:::|...|",
                         "+---+---+---+---+---+---+---+---+",
                         "|...|:::|...|:::|...|:::|...|:::|",
                         "+---+---+---+---+---+---+---+---+",
                         "|:::|...|:::|...|:::|...|:::|...|",
                         "+---+---+---+---+---+---+---+---+",
                         "|...|:::|...|:::|...|:::|...|:::|",
                         "+---+---+---+---+---+---+---+---+",
                         "|:::|...|:::|...|:::|...|:::|...|",
                         "+---+---+---+---+---+---+---+---+",
                         "|...|:::|...|:::|...|:::|...|:::|",
                         "+---+---+---+---+---+---+---+---+",
                         "|:::|...|:::|...|:::|...|:::|...|",
                         "+---+---+---+---+---+---+---+---+" };
    
     
    
    int find_r(char n){   //  找出棋子在棋盘上所对应的横坐标。
        int r = n -'1';
        r = 7 - r;
        return 2 * r + 1; 
    
    }
    
     
    
    int find_c(char n){    //  找出棋子在棋盘上所对应的纵坐标。
        int c = n - 'a';
        return 4 * c + 2;
    }
    
     
    
    int main(){
        int i, j;
        char str[Max], r, c;
    
    
        gets(str);   //  记得得用gets(),因为串内有空格符。
        for(i = 7; str[i] >= 'A' && str[i] <= 'Z'; i += 4){   //  处理白棋K, Q, R, B和N。
            r = find_r(str[i + 2]);
            c = find_c(str[i + 1]);
            map[r][c] = str[i];
        }
        for(j = i; str[j] >= 'a' && str[j] <= 'z'; j += 3){   //  处理白棋的p。
            r = find_r(str[j + 1]);
            c = find_c(str[j]);
            map[r][c] = 'P';
        }
    
    
        gets(str);
        for(i = 7; str[i] >= 'A' && str[i] <= 'Z'; i += 4){   //  处理黑棋K, Q, R, B和N。
            r = find_r(str[i + 2]);
            c = find_c(str[i + 1]);
            map[r][c] = str[i] + 32;
        }
        for(j = i; str[j] >= 'a' && str[j] <= 'z'; j += 3){   //  处理黑棋的p。
            r = find_r(str[j + 1]);
            c = find_c(str[j]);
            map[r][c] = 'p';
        }
    
    
        for(i = 0; i < 17; i ++){
            for(j = 0; j < 33; j ++)
                cout << map[i][j];
            cout << endl;
        }
        return 0;
    } 
    
    
     
    
    
    
  • 相关阅读:
    HDU_3127 WHUgirls(DP)
    ibatits
    jqGrid怎么设定水平滚动条
    poi导出EXcel
    jqGrid资料总结
    jqgrid横向滚动条
    开源网http://www.openopen.com/ajax/2_Charts.htm
    struts2国际化
    struts2结合poi导出excel
    Struts2 Action读取资源文件
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3762128.html
Copyright © 2011-2022 走看看