zoukankan      html  css  js  c++  java
  • 137

    Poker Face

    Time Limit: 2 Seconds      Memory Limit: 65536 KB

    As is known to all, coders are lack of exercise and Kato is one of them. In order to get fit, he decides to go mining in MINECRAFT. However, it is always dangerous in the mine because there are a lot of ZOMBIEs in MINECRAFT. They kill Kato time and time again when he is mining. But this time, Kato is in invincible mode and wants to observe what the ZOMBIEs' faces are like. After his obervation, he found that the ZOMBIEs' faces are regular. Now he provides you the ZOMBIEs' faces of size 8, 16 and 32, it is your task to draw the other ZOMBIEs. You should find the recursivepattern from the small cases and learn to draw bigger cases.

    Input

    There are multiple test cases. For each case there is only a number N (8 ≤ N≤ 1024, N is a power of 2), which is size of the ZOMBIE's face. The input ends with an integer less than eight.

    Output

    For each case, output the image of the ZOMBIE's face. And print an empty line after each case.

    Sample Input

    8
    16
    32
    0
    

    Sample Output

    ********
    ***  ***
    ***  ***
    ***  ***
    * **** *
    * *  * *
    * *  * *
    ********
    
    ****************
    *              *
    * ****    **** *
    * *  *    *  * *
    * *  *    *  * *
    * *  *    *  * *
    * ****    **** *
    *              *
    *   ********   *
    *   * *  * *   *
    *   * *  * *   *
    *   * **** *   *
    *   ***  ***   *
    *   ***  ***   *
    *   ***  ***   *
    ****************
    
    ********************************
    *                              *
    *                              *
    *                              *
    *   ********        ********   *
    *   *      *        *      *   *
    *   *      *        *      *   *
    *   *      *        *      *   *
    *   *      *        *      *   *
    *   *      *        *      *   *
    *   *      *        *      *   *
    *   *      *        *      *   *
    *   ********        ********   *
    *                              *
    *                              *
    *                              *
    *       ****************       *
    *       *   ***  ***   *       *
    *       *   ***  ***   *       *
    *       *   ***  ***   *       *
    *       *   * **** *   *       *
    *       *   * *  * *   *       *
    *       *   * *  * *   *       *
    *       *   ********   *       *
    *       *              *       *
    *       * ****    **** *       *
    *       * *  *    *  * *       *
    *       * *  *    *  * *       *
    *       * *  *    *  * *       *
    *       * ****    **** *       *
    *       *              *       *
    ********************************
    
    

    Hint

    The sample out put is the ZOMBIE's face of size 8, 16, 32.

    Author: ZHU, Heming

    解题:递推打印就是了。。。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <climits>
    #include <vector>
    #include <queue>
    #include <cstdlib>
    #include <string>
    #include <set>
    #include <stack>
    #define LL long long
    #define INF 0x3f3f3f3f
    #define pii pair<int,int>
    using namespace std;
    const int maxn = 2000;
    int n;
    char table[11][maxn][maxn];
    void printLine(int m,int n,int x,int y) {
        for(int i = 0; i < n; ++i)
            table[m][x][y+i] = '*';
    }
    void printR(int m,int n,int x,int y) {
        for(int i = 0; i < n-1; ++i) {
            table[m][x+i][y] = '*';
            for(int j = 1; j < n-1; ++j)
                table[m][x+i][y+j] = ' ';
            table[m][x+i][y+n-1] = '*';
        }
    }
    void printG(int m,int n) {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j)
                putchar(table[m][i][j]);
            putchar('
    ');
        }
    }
    void printB(int n,int x,int y,int m) {
        for(int i = n-1; i >= 0; --i) {
            for(int j = 0; j < n; ++j) {
                table[m][x+i][y+j] = table[m-1][i][j];
            }
        }
    }
    void draw(int m,int n) {
        printLine(m,n,0,0);
        printR(m,n,1,0);
        printLine(m,n,n-1,0);
    
        printLine(m,n>>2,n>>3,n>>3);
        printR(m,n>>2,(n>>3)+1,n>>3);
        printLine(m,n>>2,(n>>3)+(n>>2),n>>3);
    
        printLine(m,n>>2,n>>3,n-(n>>3)-(n>>2));
        printR(m,n>>2,(n>>3)+1,n-(n>>3)-(n>>2));
        printLine(m,n>>2,(n>>3)+(n>>2),n-(n>>3)-(n>>2));
    }
    void draw2(int m,int n) {
        int y = n>>2;
        int x = (n>>1);
        for(int i = (n>>1)-1; i >= 0; --i,x++) {
            for(int j = 0; j < (n>>1); ++j)
                table[m][x][y+j] = table[m-1][i][j];
        }
    }
    int main() {
        memset(table,' ',sizeof(table));
        draw(3,1<<3);
        printLine(3,4,4,2);
        table[3][5][2] = table[3][5][5] = '*';
        table[3][6][2] = table[3][6][5] = '*';
        for(int i = 4; i <= 10; ++i) {
            draw(i,1<<i);
            draw2(i,1<<i);
        }
        while(scanf("%d",&n),n >= 8) {
            int k = log2(n)+0.5;
            printG(k,n);
            putchar('
    ');
        }
        return 0;
    }
    View Code
  • 相关阅读:
    源码分析shiro认证授权流程
    shiro功能模块
    Java NIO(New I/O)的三个属性position、limit、capacity
    阻塞和非阻塞,同步和异步 总结
    小白科普:Netty有什么用?
    【异常】SSM整合quartz之org.quartz.impl.JobDetailImpl----ClassNotFoundException
    笔记本键盘字母按出来的都是快捷键
    eclipse egit提交方法
    oracle批量insert
    CAS Client 3.2.1 配置详解
  • 原文地址:https://www.cnblogs.com/crackpotisback/p/4133174.html
Copyright © 2011-2022 走看看