设为首页 加入收藏

TOP

poj 1941 The Sierpinski Fractal 递归
2015-11-21 00:58:07 来源: 作者: 【 】 浏览:1
Tags:poj 1941 The Sierpinski Fractal 递归
//poj 1941
//sep9
#include 
  
   
using namespace std;
const int maxW=2048;
const int maxH=1024;
int pow2[32];
char g[maxH+10][maxW+10];
void print(int x,int y,int n)
{
	if(n==1){
		g[x][y+1]='/';
		g[x][y+2]='\';
		g[x+1][y]='/';
		g[x+1][y+1]='_';
		g[x+1][y+2]='_';
		g[x+1][y+3]='\';
		return ;
	}
	print(x,y+pow2[n-1],n-1);
	print(x+pow2[n-1],y,n-1);
	print(x+pow2[n-1],y+pow2[n],n-1);
	return ;	
}

int main()
{
	pow2[0]=1;
	for(int i=1;i<30;++i)
		pow2[i]=pow2[i-1]*2;
	int n;
	while(scanf(%d,&n)==1&&n){
		int H=pow2[n];
		int W=pow2[n+1];
		memset(g,' ',sizeof(g));
		print(0,0,n);
		for(int i=0;i
   
    

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 1026 Ignatius and the Princ.. 下一篇POJ 1251 Jungle Roads 最小生成树

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: