P1498 nanmantotem and p1498 nanmantotem
Description
Since he arrived in the south manan, Kong Ming not only convinced Meng's pack, but also discovered the wisdom of many ethnic minorities, he found that the totem of ethnic minorities often had a fractal effect (see Hint). After being taught by the Chief, Kong Ming mastered a lot of plotting techniques, but they won't draw their totem, so he finds your grandfather's grandfather ...... Help, as the grandson of a good grandson ...... Can you do this?
Input/Output Format
Input Format:
Each data has a number, indicating the size of the totem (this size is not the same size) n <= 10
Output Format:
Totem of this size
Input and Output sample
Input example #1:
2
Output sample #1:
/\ /__\ /\ /\/__\/__\
Input example #2:
3
Output sample #2:
/\/__\/\/\/__\/__\/\/\/__\/__\/\/\/\/\/__\/__\/ __\/__\
This is a pitfall. The most basic point of governance is not n = 1, but n = 2.
We can split each image into three copies.
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 const int MAXN=2050; 7 int pow2[]={1,2,4,8,16,32,64,128,256,512,1024,2048}; 8 //char a[10][10]={{' ',' ',' ','/','\\',' ',' ',' '}, 9 // {' ',' ','/','_','_','\\',' ',' '}};10 int n;11 char a[MAXN][MAXN];12 void work(int x,int y)13 {14 a[x][y]='/';15 a[x][y+1]='\\';16 a[x+1][y-1]='/';17 a[x+1][y+2]='\\';18 a[x+1][y]='_';19 a[x+1][y+1]='_';20 }21 void draw(int x,int y,int deep)22 {23 if(deep==1)24 {25 work(x,y);26 return ;27 }28 draw(x,y,deep-1);29 draw(x+pow2[deep-1],y-pow2[deep-1],deep-1);30 draw(x+pow2[deep-1],y+pow2[deep-1],deep-1);31 }32 int main()33 {34 //ios::sync_with_stdio(false);35 cin>>n;36 memset(a,' ',sizeof(a));37 draw(0,pow2[n],n);38 for(int i=0;i<pow2[n+1];++i)39 {40 for(int j=1;j<=pow2[n+1];++j)41 putchar(a[i][j]);42 putchar('\n');43 }44 return 0;45 }