Hey I was having a major problem in creating a complex number pyramid. The user inputs a number of rows, but if it exceeds 20 it would go off page, so 1-20. I have a nested For loop (using QBasic) that looks something like this
for x = 1 to rows
for y = 1 to x
(CODE)
next y
(CODE)
next x
IT would be simple ... but the pyramid must look something like this
That would be for 4 rows, and it continues on in that pattern, with the last number increasing 1 per row....what ive come up with is creating a addition type formula, but i keep gettin the wrong solution and ive changed it about a million different ways so i scratched it all together..... :mad: lol, anyone have an idea on the coding ill need to create the 21012 type pattern in the second For loop....or am i setting it up completly wrong and need a new method of doing this??
CLS
row = 0
For y = 0 to 19 ' 20 rows
For x = 0 to row
print "x" ' i cant remember the code for adjacent text
Next
print " " 'new line
row = row + 1 ' increment row
Next
this should give you
0
01
012
0123
...
and im sure you can go back over the loop and draw the other side :)
CLS
row = 0
For y = 0 to 19 ' 20 rows
For x = 0 to row
print "x" ' i cant remember the code for adjacent text
Next
print " " 'new line
row = row + 1 ' increment row
Next
this should give you
0
01
012
0123
...
and im sure you can go back over the loop and draw the other side :)
To achieve the single line printing, please refer the below code. Hope this helps.....
Dim res As String
res = ""
row = 0
For y = 1 To 6 ' 20 rows
For x = 1 To row
res = res & "x"
Next
Print res
res = ""
row = row + 1 ' increment row
Next