PetroChina "Recursive" Fractal not submitted

Source: Internet
Author: User

Issue C: "Recursive" Fractal time limit: 1 Sec memory limit: MB
Submitted by: 17 Solution:
Submitted State [Discussion Version] The topic describes fractal and has the morphological characteristics of filling space in non-integer dimensions. It is usually defined as "a rough or fragmented geometric shape, which can be divided into several parts, and each part (at least approximately) is the overall reduced shape", which has a self-similar nature.


The box-shaped fractal is defined as follows: A fractal with a degree of 1 is a fractal with an X-degree of 2: X × x x x if B (n-1) is used to represent a box-shaped fractal with a degree of n-1, the box-type fractal with the degree n is defined as: B (n-1) b (n-1) b (n-1) b -1) B (n-1) Your task is to output a box-shaped fractal with a degree of N. The input input contains multiple test data, one row for each test data, and a positive integer n, (n<=7). Enter last behavior-1, indicating the end. Output for each test data, with x represents the output of the box type, each test data corresponding to the output of a string of "----------", the end of each line do not output any extra space, otherwise the result is a bad format. Sample input
1234-1
Sample output
x----------x x xx x----------x x x x x xx x x x x x x × x xx x x x x   ----------  x x x x x x x x x x     XX x   x x x x x x x/X x x xx x x x x x × x x x x x     xx x          x x x x x x
    x x x x x x x x × x x x x x x x         x
    x x x x x × x x x x x x x   x< x x × x x x x x C65/>x x x x x x ×     XX x   x         x x x x   ----------
idea: Note that there can be no space at the end of each line, or it will be malformed.
X, y represents the coordinates of the upper-left corner of each diagram.
Code:
#include <iostream>#include<cstdio>#include<cmath>#include<cstring>using namespacestd;Chara[730][730];voidbintNintXinty) {    if(n==1) {A[x][y]='X'; }Else{        intM=pow (3, N-2); B (N-1, x, y); B (N-1, x,y+2*m); B (N-1, x+m,y+m); B (N-1, x+2*m,y); B (N-1, x+2*m,y+2*m); }}intMain () {intN;  while(SCANF ("%d", &n)!=eof&&n!=-1) {memset (A,' ',sizeof(a)); B (N,1,1); //spaces at the end of each line are removed         for(intI=1; I<pow (3, N-1); i++){             for(intJ=pow (3, N-1);j>1; j--){                if(a[i][j]!='X') {A[i][j]=' /'; }Else{                     Break; }            }        }        //Output Image         for(intI=1; I<=pow (3, N-1); i++){             for(intj=1; J<=pow (3, N-1); J + +){                if(a[i][j]!=' /') {printf ("%c", A[i][j]); }} printf ("\ n"); } printf ("----------\ n"); }    return 0;}
View Code



PetroChina "Recursive" Fractal not submitted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.