Hi,
Making 4 pyramid vertically. First of all, it is easlily run in horizotally, what I want is that those pyramid run vertically, It means first one is print
------*------
-----***-----
----*****----
---*******---
--*********--
-***********-
*************
-***********-
--*********--
---*******---
----*****----
-----***-----
------*------
and then the next one doesn't print under this pyramid, I want the another one is print beside this pyramid as it it I want to print 4 or 3 pyramid. Please let me know.
7 replies to this topic
#1
Posted 26 May 2011 - 08:49 AM
|
|
|
#2
Posted 26 May 2011 - 09:00 AM
Forgive me if I don't quite address your specific question. Your wording was a bit difficult to understand.
What I assume you mean is that you are generating this character pattern, and instead of generating one after another (printing them vertically in the console), you want to print them side-by-side. In order to do this, you will need to generate all of the patterns simultaneously and print the first line of each pattern before printing a newline character.
In other words, generate the first line of the first pattern and print it out, followed by a space if you wish, then generate the first line for the 2nd pattern, followed by a space, the first line of the 3rd pattern, space, the first line of the 4th pattern, followed by a newline. Then you repeat printing the 2nd line of the 1st pattern, the 2nd line of the 2nd pattern, and so on.
The control structures required for such an algorithm should be apparent based on my description above.
What I assume you mean is that you are generating this character pattern, and instead of generating one after another (printing them vertically in the console), you want to print them side-by-side. In order to do this, you will need to generate all of the patterns simultaneously and print the first line of each pattern before printing a newline character.
In other words, generate the first line of the first pattern and print it out, followed by a space if you wish, then generate the first line for the 2nd pattern, followed by a space, the first line of the 3rd pattern, space, the first line of the 4th pattern, followed by a newline. Then you repeat printing the 2nd line of the 1st pattern, the 2nd line of the 2nd pattern, and so on.
The control structures required for such an algorithm should be apparent based on my description above.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#3
Posted 26 May 2011 - 09:48 AM
My concern is that I want to make 3 or 4 pyrmid like above. I have already made this pyramid. But what I want to do is that all pyramids print on the console window side-by-side. Not underneath the pyramid. like example:
** ** ** same as it is print my pyramid. I hope now it is understood.
** ** ** same as it is print my pyramid. I hope now it is understood.
#4
Posted 26 May 2011 - 10:14 AM
Then my above suggestion should do exactly that. When you generate the first line and print it out, repeat that process for as many times as the number of pyramids you want before you print the newline character.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#5
Posted 26 May 2011 - 10:23 AM
Can you make it becuse when I make this program it prints the first pyramid then second one (beneath the first one) like this. Coudl you make 2 pyrmide which prints side by side.?
#6
Posted 27 May 2011 - 05:31 AM
I'm not going to do the work for you. If you give it your best effort and still cannot get it to work, then I will be glad to take a look at your source code and give you pointers.
Just follow this pseudocode and give it your best shot. You will have to reorganize the structure of your program to switch from vertical printout to horizontal.
That's probably the simplest solution there. You can improve efficiency by moving the innermost loop (K) to just before the 2nd loop (J) (at the same nest level as the 2nd loop), and have your program print the pattern line to a string rather than the console. Then, in the K loop, simply print out the same string each time so it doesn't have to regenerate it for each pyramid.
Go ahead and code that up and see what you get.
Just follow this pseudocode and give it your best shot. You will have to reorganize the structure of your program to switch from vertical printout to horizontal.
Loop For I from 0 to Pyramid.Height: Loop For J from 0 to Number of Pyramids desired: Loop For K from 0 to Pyramid.Width: Print character from Pyramid at Line I and Column K. Next K Next J Next I
That's probably the simplest solution there. You can improve efficiency by moving the innermost loop (K) to just before the 2nd loop (J) (at the same nest level as the 2nd loop), and have your program print the pattern line to a string rather than the console. Then, in the K loop, simply print out the same string each time so it doesn't have to regenerate it for each pyramid.
Go ahead and code that up and see what you get.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#7
Posted 27 May 2011 - 09:10 AM
Okay, let me do itselft, If I am unable to do it I'll provide my source code of this program what I am doing and let know where I have done a mistake.
Thanks for encouraging me!
Thanks for encouraging me!
#8
Posted 30 May 2011 - 10:49 AM
desireadil said:
Okay, let me do itselft, If I am unable to do it I'll provide my source code of this program what I am doing and let know where I have done a mistake.
Thanks for encouraging me!
Thanks for encouraging me!
I have done with the help of you.
Thanks and regards!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









