A fractal is an object or quantity that displays self-similarity, in a somewhat technical sense, on all scales. The object need not exhibit exactly the same structure at all scales, but the same "type" of structures must appear on all scales.

A box fractal is defined as below :

  • A box fractal of degree 1 is simply

    X
    
  • A box fractal of degree 2 is
    X X
     X
    X X
    
  • If using B(n - 1) to represent the box fractal of degree n - 1, then a box fractal of degree n is defined recursively as following
    B(n - 1)          B(n - 1)
             B(n - 1)
    B(n - 1)          B(n - 1)
    

Your task is to draw a box fractal of degree n.

Input

The input consists of several test cases. Each line of the
input contains a positive integer n which is no greater than 7. The last
line of input is a negative integer -1 indicating the end of input.

Output

For each test case, output the box fractal using the 'X'
notation. Please notice that 'X' is an uppercase letter. Print a line
with only a single dash after each test case. Don't output any trailing
spaces at the end of each line, or you may get an 'Presentation Error'!

题意:输出n层"X"型分型,遇到-1时结束输入,可以看成一个3X3的正方形X为原型,输出后还要在另一行输出一个"-"

注意:图形最右方"X"后的空格不能输出,这里给出的一个解决方法是单独把他们标记出来,输出时检测这些标记来控制输出格式

 #include<iostream>
 #include<cstdio>
 #include<cstring>
 #define ll long long
 using namespace std;
 ;
 ,b;
 char mp[amn][amn];
 char ans[amn][amn];
 void solve(int x,int y,int tot)
 {
     )
     {
         ans[x][y]='X';
         return;
     }
     int tes=tot/a;
     for(int i=x; i<tot+x; i+=tes)///注意这里i=x,j=y,找了好久才发现错误....
     {
         for(int j=y; j<tot+y; j+=tes)
         {
             if(mp[(i-x)/tes][(j-y)/tes]=='X')
             {
                 solve(i,j,tes);
             }
         }
     }
 }
 int main()
 {

     )
     {
         ; i<; i++)
         {
             ; j<; j++)
             {
                 ||i==)&&(j==||j==))||(i==&&j==))mp[i][j]='X';
                 else mp[i][j]=' ';
             }
         }
         ;///注意初始化
         ; i<b; i++)c*=a;
         ; i<c; i++)
             ; j<c; j++)
                 ans[i][j]=' ';
         solve(,,c);
         ; i<c; i++)
         {
             ; j>=; j--)///这里是从每一行的最后一个元素开始检测
             {
                 if(ans[i][j]==' ')///将空格标记,遇到第一个"X"时跳出本次循环
                     ans[i][j]='*';
                 else break;
             }
         }
         ; i<c; i++)
         {
             ; j<c; j++)
             {
                 if(ans[i][j]!='*')///如果这个不是被标记的元素则输出
                     printf("%c",ans[i][j]);
                 else break;
             }

             printf("\n");
         }
         printf("-\n");
     }
 }

ZOJ - 2423-Fractal的更多相关文章

  1. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  2. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  3. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  4. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  5. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  6. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  7. ZOJ Problem Set - 1001 A + B Problem

    ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...

  8. zoj 1788 Quad Trees

    zoj 1788 先输入初始化MAP ,然后要根据MAP 建立一个四分树,自下而上建立,先建立完整的一棵树,然后根据四个相邻的格 值相同则进行合并,(这又是递归的伟大),逐次向上递归 四分树建立完后, ...

  9. ZOJ 1958. Friends

    题目链接: ZOJ 1958. Friends 题目简介: (1)题目中的集合由 A-Z 的大写字母组成,例如 "{ABC}" 的字符串表示 A,B,C 组成的集合. (2)用运算 ...

  10. ZOJ

    某年浙大研究生考试的题目. 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. 是否AC的规则如下:1. zoj能AC:2. 若字符串形式为xzojx,则也能AC, ...

随机推荐

  1. 浅谈Kotlin(二):基本类型、基本语法、代码风格

    浅谈Kotlin(一):简介及Android Studio中配置 浅谈Kotlin(二):基本类型.基本语法.代码风格 浅谈Kotlin(三):类 浅谈Kotlin(四):控制流 通过上面的文章,在A ...

  2. C#字典Dictionay多线程读是否是安全的

    答案:是线程安全的,只读不写多线程下,完全不需要加锁! 测试代码: using System; using System.Diagnostics; using System.Threading; us ...

  3. Android使用Glide加载https链接的图片不显示的原因

    平时我们使用Glide加载http网址的图片的时候,图片可以正常加载出来,但是如果服务器端加上了安全认证,当加载自签名的https图片的时候就会报如下错误(证书路径验证异常). 我们如果不修改Glid ...

  4. <自动化测试方案书>方案书目录排版

    自动化测试方案书 一.介绍 QQ交流群:585499566 这篇是一个系列,用来给需要做自动化测试方案的人做个参考,文章的内容是我收集网上和自己工作经验所得,希望能够给你们有所帮助 背景:因为工作需要 ...

  5. Python MySQL事务、引擎、索引及第三方库sqlalchemy

    本节内容 1.数据库介绍2.事务3.引擎4.索引5.ORM sqlalchemy 1.数据库介绍 什么是数据库? 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,每个数据库都有一 ...

  6. 卸载时候出现: windows installer 程序有问题。此安装需要的dll不能运行 的一个解决方法

    卸载时候出现: windows installer 程序有问题.此安装需要的dll不能运行 安装Your Uninstaller来卸载

  7. 关于Inception默认配置的一个坑

    本文地址:https://www.cnblogs.com/ajiangg/p/9850902.html 约半年前上线了去哪儿的开源审核工具Inception(最近发现已经闭源了.....)以及基于In ...

  8. 反射生成 INSERT 多个对象的 SQL 语句(批量插入)

    + View code private static void insertObject(List<?> objectList) throws IllegalAccessException ...

  9. Linux进程调度器概述--Linux进程的管理与调度(十五)

    调度器面对的情形就是这样, 其任务是在程序之间共享CPU时间, 创造并行执行的错觉, 该任务分为两个不同的部分, 其中一个涉及调度策略, 另外一个涉及上下文切换. 1 背景知识 1.1 什么是调度器 ...

  10. shell linux 环境下循环遍历文件夹下所有文件

    demofun(){ ` do if test -f $file then echo "file: $file" elif test -d $file then echo &quo ...