• POJ2996 Help Me with the Game(模拟)


    题目链接

    分析:

    简单模拟。

    #include <iostream>
    #include <queue>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    
    using namespace std;
    
    char White[] = "KQRBNP";
    char Black[] = "kqrbnp";
    
    char G[10][10], s[50];
    
    int main(){
        memset(G, 0, sizeof(G));
    
        for(int i=0; i<17; i++) {
            scanf("%s", s);
            if(i % 2 == 1) {
                for(int j=0; s[j]; j++) {
                    if(isalpha(s[j])) G[i/2][(j-2)/4] = s[j];
                }
            }
        }
    
        bool first = true;
    
        printf("White: ");
        for(int k=0; k<6; k++) {
            for(int i=7; i>=0; i--) {
                for(int j=0; j<8; j++) {
                    if(G[i][j] == White[k]) {
                        if(first) {
                            printf("%c%c%d", White[k], 'a'+j, 8-i);
                            first = false;
                        }
                        else {
                            if(White[k] == 'P')
                                printf(",%c%d", 'a'+j, 8-i);
                            else printf(",%c%c%d", White[k], 'a'+j, 8-i);
                        }
                    }
                }
            }
        }
        putchar('
    ');
    
        first = true;
    
        printf("Black: ");
        for(int k=0; k<6; k++) {
            for(int i=0; i<8; i++) {
                for(int j=0; j<8; j++) {
                    if(G[i][j] == Black[k]) {
                        if(first) {
                            printf("%c%c%d", Black[k]+'A'-'a', 'a'+j, 8-i);
                            first = false;
                        }
                        else {
                            if(Black[k] == 'p')
                                printf(",%c%d", 'a'+j, 8-i);
                            else printf(",%c%c%d", Black[k]+'A'-'a', 'a'+j, 8-i);
                        }
                    }
                }
            }
        }
        putchar('
    ');
    
        return 0;
    }
  • 相关阅读:
    汉语-成语:老谋深算
    汉语-成语:深谋远虑
    汉语-词语:审题
    汉语-成语:未雨绸缪
    汉语-成语:精养蓄锐
    汉语-成语:厚积薄发
    汉语-成语:韬光养晦
    汉语-词语:忍耐
    菌类:羊肚菌
    养生-菌类:松露
  • 原文地址:https://www.cnblogs.com/tanhehe/p/3237543.html
Copyright © 2020-2023  润新知