ZOJ - 2423-Fractal
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.
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的更多相关文章
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- ZOJ Problem Set - 1001 A + B Problem
ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...
- zoj 1788 Quad Trees
zoj 1788 先输入初始化MAP ,然后要根据MAP 建立一个四分树,自下而上建立,先建立完整的一棵树,然后根据四个相邻的格 值相同则进行合并,(这又是递归的伟大),逐次向上递归 四分树建立完后, ...
- ZOJ 1958. Friends
题目链接: ZOJ 1958. Friends 题目简介: (1)题目中的集合由 A-Z 的大写字母组成,例如 "{ABC}" 的字符串表示 A,B,C 组成的集合. (2)用运算 ...
- ZOJ
某年浙大研究生考试的题目. 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. 是否AC的规则如下:1. zoj能AC:2. 若字符串形式为xzojx,则也能AC, ...
随机推荐
- Python 标准类库-Windows特殊服务之msvcrt
标准类库-Windows特殊服务之msvcrt by:授客 QQ:1033553122 广告:出售自研自动化小平台(无需编码也可用),有需要请联系 测试环境 win7 64位 Python 3.4 ...
- loadrunner 脚本优化-参数化之Parameter List参数取值
脚本优化-参数化之Parameter List参数取值 by:授客 QQ:1033553122 参数取值选项 Select next row Update value on 以上两个选项是改变参数化取 ...
- Android SDK manager里面什么是必须下载的?
最近公司来了位新同事,由于需要配置Android环境,但是在配置的时候却发现sdk很大,很占用空间,想复制给同事也觉得不方便,于是根据下面的图删除了一些不必要的api. 根据官方文档的描述SDK To ...
- Python绘图工具Plotly的简单使用
1.Plotly被称为史上最好的绘图工具之一,为了更好的展示金融数据的复杂性. Plotly的官方网站为:https://plot.ly/ python量化的关键是金融数据可视化,无论是传统的K线图, ...
- Servlet以及单例设计模式
1.Servlet概述 a)Servlet,全城是Servlet Applet,服务器端小程序,是一个接口,定义了若干方法,要求所有的Servlet必须实现. b)Servlet用于接收客户端的请求, ...
- SQL Server如何定位自定义标量函数被那个SQL调用次数最多浅析
前阵子遇到一个很是棘手的问题,监控系统DPA发现某个自定义标量函数被调用的次数非常高,高到一个离谱的程度.然后在Troubleshooting这个问题的时候,确实遇到了一些问题让我很是纠结,下文是解决 ...
- ApplicationContext 配置里dataSource mysql连接数据源,设置ssl和utf-8
?useUnicode&useSSL=false
- [20181015]为什么是3秒.txt
[20181015]为什么是3秒.txt --//以前测试:连接http://blog.itpub.net/267265/viewspace-2144765/=>为什么是12秒.txt.--// ...
- idea2018版tomcat基本配置
前言 在配置tomcat之前,要先创建一个javaweb的工程 打开idea的主界面,在菜单中点击File,出现以下的图 点击选择 Application Server 点击选择 Tomcat Ser ...
- python第一百零九天---Django 4
session :1. Session 基于Cookie做用户验证时:敏感信息不适合放在cookie中 a. Session原理 Cookie是保存在用户浏览器端的键值对 Session是保存在服务器 ...