标签:数字 分形 main hint getc pen 输入输出 ++ tchar
自从到了南蛮之地,孔明不仅把孟获收拾的服服帖帖,而且还发现了不少少数民族的智慧,他发现少数民族的图腾往往有着一种分形的效果(看Hint),在得到了酋长的传授后,孔明掌握了不少绘图技术,但唯独不会画他们的图腾,于是他找上了你的爷爷的爷爷的爷爷的爷爷……帮忙,作为一个好孙子的孙子的孙子的孙子……你能做到吗?
输入格式:
每个数据一个数字,表示图腾的大小(此大小非彼大小) n<=10
输出格式:
这个大小的图腾
2
/ /__ /\ //__\/__
3
/ /__ /\ / /__\/__ /\ / /__\ /__ /\ /\ /\ //__\/__\/__\/__\
一道好看的模拟题,一直对我笑
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<queue>
using namespace std;
int a[1033][1033];
int read()
{
int ans=0,f=1;char ch=getchar();
while(!isdigit(ch)) {if(ch==‘-‘) f=-1;ch=getchar();}
while(isdigit(ch)) {ans=ans*10+ch-‘0‘;ch=getchar();}
return ans*f;
}
void make(int i,int j,int si)
{
if(si==1)
{
a[i][j]=a[i+1][j-1]=1;
a[i][j+1]=a[i+1][j+2]=2;
a[i+1][j]=a[i+1][j+1]=3;
return;
}
make(i,j,si-1);
make(i+(1<<si-1),j-(1<<si-1),si-1);
make(i+(1<<si-1),j+(1<<si-1),si-1);
}
int main()
{
freopen("o.out","w",stdout);
int n=read(),r,c;
r=(1<<n);c=4*(1<<n-1);
make(1,c>>1,n);
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{
switch(a[i][j]){
case 0:putchar(‘ ‘);
break;
case 1:putchar(‘/‘);
break;
case 2:putchar(‘\\‘);
break;
case 3:putchar(‘_‘);
break;
}
}
printf("\n");
}
return 0;
}
标签:数字 分形 main hint getc pen 输入输出 ++ tchar
原文地址:http://www.cnblogs.com/charlotte-o/p/7637289.html