2 shunfurh shunfurh 于 2016.12.31 23:07 提问

Cantoring Along

Description

The Cantor set was discovered by Georg Cantor. It is one of the simpler fractals. It is the result of an infinite process, so for this program, printing an approximation of the whole set is enough. The following steps describe one way of obtaining the desired output for a given order Cantor set:
Start with a string of dashes, with length 3order
Replace the middle third of the line of dashes with spaces. You are left with two lines of dashes at each end of the original string.
Replace the middle third of each line of dashes with spaces. Repeat until the lines consist of a single dash.

For example, if the order of approximation is 3, start with a string of 27 dashes:

Remove the middle third of the string:


and remove the middle third of each piece:


and again:


The process stops here, when the groups of dashes are all of length 1. You should not print the intermediate steps in your program. Only the final result, given by the last line above, should be displayed.
Input

Each line of input will be a single number between 0 and 12, inclusive, indicating the order of the approximation. The input stops when end-of-file is reached.
Output

You must output the approximation of the Cantor set, followed by a newline. There is no whitespace before or after your Cantor set approximation. The only characters that should appear on your line are '-' and ' '. Each set is followed by a newline, but there should be no extra newlines in your output.
Sample Input

0
1
3
2
Sample Output

  • - - - - - - - - - - - - -

1个回答

caozhy
caozhy   Ds   Rxr 2016.12.31 23:29
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Cantoring Along pku2876
Cantoring Along Time Limit:1000MS  Memory Limit:65536KTotal Submit:1310 Accepted:788 DescriptionThe Cantor set was discovered by Georg Cantor. It is one of the simpler fractals. It is the result of
POJ 2876 Cantoring Along 递归
【题意简述】:本题让我们输入单位为3的“-”的个数,接下来对这条线进行切割,每次切掉中间的三分之一,用空格替换,直到“-”的每一段长度为1,打印输出。 【思路】:递归题,用时稍久,希望你写出用时更短的代码。我们可以将一个数组赋值为空格,然后对该数组进行分割,同样满足题意,每次丢掉中间的三分之一,然后递归循环此过程,将其划分的更小,直到分割到长度为1,结束返回。。 /* 1128K 375Ms
Android编译遇到点9图片错误:No marked region found along edge. - Found along left edge.
http://androidren.com/index.php?qa=330&qa_1=android%E7%BC%96%E8%AF%91%E9%81%87%E5%88%B0%E7%82%B99%E5%9B%BE%E7%89%87%E9%94%99%E8%AF%AF%EF%BC%9Ano-marked-region-found-along-found-along 这个是因为点9图的某一个
开源推荐系统crab里面的一处bug
作为一款python写的开源推荐系统,crab总体还是很不错的。它最大的特色在于很好的实现了协同过滤算法,包括基于用户的协同过滤和基于物品的协同过滤。在阅读源码的过程中发现基于用户的协同过滤算法部分有一处bug,对最后的推荐结果影响非常的大,这里特意指出来。 基于用户的协同过滤算法步骤大致包含: 1、基于用户对物品的行为构建用户物品评分矩阵; 2、基于评分矩阵计算用户的相似度; 3、根据相似度找n个
Instance Along Curve - Maya API Plugin
视频:https://www.youtube.com/watch?v=k4i_dZjxVr0 代码:https://github.com/mmerchante/instanceAlongCurve/blob/master/instanceAlongCurve.py
Python科学计算-----NumPy(一)
Numpy NumPy 是 Numerical Python 的简称,是Python的高性能计算和数据分析的基础核心包。与Python的基本数据类型相比,其具有以下突出优势: 提供功能更强大的高维数组(N-dimensional)对象 强大的广播功能(broadcasting),便于矢量化数组操作(直接对数组进行数据处理,而不需要编写循环) 集成了 C/C++ 以及 Fortr
IndexError:boolean index did not match indexed array along dimension 0
IndexError: boolean index did not match indexed array along dimension 0; dimension is 8 but corresponding boolean dimension is 7在学习回归算法的时候,使用sklearn.linear_model下的RandomizedLogisticRegression(下列简称为RLR...
Error:Can't have more than one marked region along edge.
最近我在编译项目的时候出现了以下异常: Error:Can't have more than one marked region along edge. 出现这个异常是因为我在 .9 图的右侧画了两条线,由于 .9 图的上边界和左边界的划线是负责拉伸扩展的,而下边界和右边界划线则是内容区域,所以 .9 图不允许右侧和下边界有两条划线,而左边界和上边界则没有问题。
Poj 3069 Saruman's Army【贪心】
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5742   Accepted: 2942 Description Saruman the White must lead his army along a straight pa
.9图片报错mergeDebugResources. xx.9.png Can't have more than one marked region along edge
今天在自己做.9图片的时候,由于很久没有做了,报了一个错误,花了点小时间,不多说直接上错 然后我们就去看看日志详情到底是什么错,有的人会不知道怎么打开这个日志详情,如下图,点击那个按钮就行了。 然后就发现了这段日志,日志说的很明显,.9图片画错了,不能有超过一个标记在边缘处,但是有人会说这什么错啊,没见过。大兄弟,不着急,当时本人遇到的时候也是一脸懵逼,于是就上网找了下.9怎么