栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1975 The Sierpinski Fractal

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1975 The Sierpinski Fractal

#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <iostream>#include <queue>#include <stack>#include <map>#include <vector>#include <algorithm>#define N 15#define M#define E#define inf 0x3f3f3f3f#define eps 1e-8#define linf (LL)1<<60#define dinf 1e20#define LL long long#define clr(a,b) memset(a,b,sizeof(a))#define D(a) ((a)*(a))using namespace std;int d;char gra[5][5];int r[N],c[N];char gc(int x,int y,int d){    if(d==1)return gra[x][y];    if(x>=0&&x<r[d-1]&&((y>=0&&y<c[d-1]/2)||(y>=c[d-1]/2*3&&y<c[d])))return ' ';    if(x>=0&&x<r[d-1])        return gc(x,y-c[d-1]/2,d-1);    if(y<c[d-1])        return gc(x-r[d-1],y,d-1);    return gc(x-r[d-1],y-c[d-1],d-1);}int main(){    gra[0][0]=' ';gra[0][1]='/';gra[0][2]='\';gra[0][3]=' ';    gra[1][0]='/';gra[1][1]='_';gra[1][2]='_';gra[1][3]='\';    r[1]=2;c[1]=4;    for(int i=2;i<=10;i++)    {        r[i]=r[i-1]*2;        c[i]=c[i-1]*2;    }    while(scanf("%d",&d),d)    {        for(int i=0;i<r[d];i++)        { int lim=-1; for(int j=c[d]-1;j>=0;j--)     if(gc(i,j,d)!=' ')     {         lim=j;         break;     } for(int j=0;j<=lim;j++)     printf("%c",gc(i,j,d)); puts("");        }        puts("");    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/367626.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号