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 = ;
int n;
char table[][maxn][maxn];
void printLine(int m,int n,int x,int y) {
for(int i = ; i < n; ++i)
table[m][x][y+i] = '*';
}
void printR(int m,int n,int x,int y) {
for(int i = ; i < n-; ++i) {
table[m][x+i][y] = '*';
for(int j = ; j < n-; ++j)
table[m][x+i][y+j] = ' ';
table[m][x+i][y+n-] = '*';
}
}
void printG(int m,int n) {
for(int i = ; i < n; ++i) {
for(int j = ; j < n; ++j)
putchar(table[m][i][j]);
putchar('\n');
}
}
void printB(int n,int x,int y,int m) {
for(int i = n-; i >= ; --i) {
for(int j = ; j < n; ++j) {
table[m][x+i][y+j] = table[m-][i][j];
}
}
}
void draw(int m,int n) {
printLine(m,n,,);
printR(m,n,,);
printLine(m,n,n-,); printLine(m,n>>,n>>,n>>);
printR(m,n>>,(n>>)+,n>>);
printLine(m,n>>,(n>>)+(n>>),n>>); printLine(m,n>>,n>>,n-(n>>)-(n>>));
printR(m,n>>,(n>>)+,n-(n>>)-(n>>));
printLine(m,n>>,(n>>)+(n>>),n-(n>>)-(n>>));
}
void draw2(int m,int n) {
int y = n>>;
int x = (n>>);
for(int i = (n>>)-; i >= ; --i,x++) {
for(int j = ; j < (n>>); ++j)
table[m][x][y+j] = table[m-][i][j];
}
}
int main() {
memset(table,' ',sizeof(table));
draw(,<<);
printLine(,,,);
table[][][] = table[][][] = '*';
table[][][] = table[][][] = '*';
for(int i = ; i <= ; ++i) {
draw(i,<<i);
draw2(i,<<i);
}
while(scanf("%d",&n),n >= ) {
int k = log2(n)+0.5;
printG(k,n);
putchar('\n');
}
return ;
}

最新文章

  1. linux awk的使用
  2. ArcGIS Wpf MarkerSymbol 图形符号无法序列化为 JSON
  3. 重拾java系列一java基础(1)
  4. Github、Jekyll 搭建及优化静态博客方法指南
  5. .net软件工程师面试题(参考答案)
  6. [Unit Testing] Angular Unit Testing, ui-router, httpbackend and spy
  7. asp.net mvc cooike 购物车 如何实现
  8. linux 虚机增加硬盘大小 转自
  9. CUDA samples 2.3节 用CUDA示例来创建CUDA项目
  10. JDBC在getConnection之前为什么要调用Class.forName(转)
  11. FrameBuffer系列 之 相关结构与结构体
  12. ConcurrentHashMap1.7和1.8的不同实现
  13. Commons-DbUtils
  14. 在tensorflow中使用batch normalization
  15. window.location.herf=url参数有中文,到后台乱码问题解决
  16. matlab 设定坐标比例
  17. Laravel 5 中使用 JWT(Json Web Token) 实现基于API的用户认证
  18. UNIX 家族及Linux
  19. HTML(具体代码看笔记本)
  20. oracle批量update

热门文章

  1. Avalon.js 实现列表
  2. JAVA jsp page指令的属性 errorPage 和isErrorPage
  3. HDU 4069 数独
  4. Linux学习总结(12)——Linux必须学会的60个命令
  5. Qt之QSS(语法高亮)
  6. CI框架源代码阅读笔记2 一切的入口 index.php
  7. 转:iOS app支付宝接口调用的一点总结(补充支付宝SDK&amp;Demo下载地址)
  8. IIS预编译提升载入速度
  9. mongodb E11000 duplicate key error collection: index: _id_ dup key
  10. bzoj1433: [ZJOI2009]假期的宿舍(最大二分图匹配)