ok what you need to do is come up with a basic algorithm. your basic algorithm in this case would be the first line contains the n number of characters. taking from your eg lets say its a 6. note that ur max characters is also the max num of lines you will have. so basically with a 6 u have 6 lines of display wea first line has no space sec has one and so forth. note this would give u a irregular pyramid. now lets say you have a num x = 0 so in in the first line u print n and do n-1 until u reach x.wen u reach x print a \n. for the sec line start printing at n again n go until x+1.wen u reach x+1 print a \n. go ahead using this algorithm and you will come with your solution.now to make your program small and since you will use the same algorithm again for n number of lines you will need to get help from a loop.try and go with small eg nums you will be able to get it. if any other queries let me know. note that i have assumed that the pyramid will be irregular coz u cannot print a half space in ur screen
kesh1000
Junior Poster in Training
70 posts since May 2009
Reputation Points: 10
Solved Threads: 3
Use a loop printing one space to the screen each time through the loop. When you are done with the loop it will look like you printed a string of spaces all at once.
As an alternative to doing everyting on the fly you could use two arrays (tables) of strings, one containing the string of spaces you need and the other containing the string of numbers you need, printing each string as you need them for each line of the pyramid. In addition to being comfortable using loops, table look up protocols are another nice tool to have in your tool box, so working out the solution using both approaches isn't necessarily the worst idea.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396