The Pictures Above area Hilbert Curve.You Can See a Hilbert Curve with a Certain Recursion Depth N IS Composed of Four Different Hilbert Curves With A Certain Recursion Depth N-1 and Three Segments.
For this problem, you are to output the hilbert curve up to a ceert 'x'.draw the smallest Hilbert Curve (That IS Not Divided Any Further) AS FOLLOWS:
Xxx
X
Xxx
To Seeh How To Draw Larger Hilbert Curve, Take a Look At The Sample Output.
INPUTTHE INPUT CONTAINS Several Testcases. Each Is Specified by AN Integer N (1 Outputfor Each Test Case, Output The Hilbert Curve with The Certain Recursion Depth N.The Output Must Not Contain Any Trailing Blanks. Print An Empty Line After Each Test Case. Sample Input 2 3 Sample Output XXXXX X X x x XXX XXX X XXX XXX X x x XXXXX X XXXX XXXXX XXX X x x x x XXX XXX XXX XXX X x x XXX xxx x xxx x X x x x x x Xxxxx x xxx xxx X Xxxxx x xxx xxx X x x x x x XXX xxx x xxx x X x x XXX XXX XXX XXX X x x x x XXXX XXXXX XXX #include Using namespace std; void main () { Int lines [9]; LINES [0] = 1; For (int i = 1; i <9; i ) LINES [I] = lines [i-1] * 2 1; Char Hilbert [520] [520]; Hilbert [0] [0] = 'x'; INT r = 1; For (int i = 1; i <9; i ) { For (int J = 0; j For (int K = 0; k { Hilbert [J] [R 1 K] = Hilbert [K] [R-1-J]; Hilbert [R 1 J] [K] = Hilbert [J] [K]; Hilbert [R 1 J] [R 1 K] = Hilbert [R-1-K] [J]; } Hilbert [0] [R] = 'x'; Hilbert [r] [r-1] = 'x'; Hilbert [2 * r] [r] = 'x'; R = r * 2 1; } Int n; While (CIN >> N) { For (int i = 0; i INT LEN = line [n] -1; While (Hilbert [i] [len]! = 'x') Len -; For (int J = 0; j <= le; j ) IF (Hilbert [i] [j] == 'x') COUT << Hilbert [i] [j]; Else Cout << ''; Cout << Endl; } Cout << Endl; } } There is no initialization of the array, and if all, it is full of space, and the time is time to printed.