Posts: 3,368
Threads: 195
Joined: Jan 2003
Basic program (er) is from a question on qbasic.com. how to do:
for i% = 1 to n%
for j% = 1 to n-1
for k% = 1 to n-2
for l% = 1 to n-3
for m% = 1 to 2
next i%
etc.
n% times.
--------------------
A gradient is good.
Could also change numbers to symbols.... or shades... or change the equation.......
Code:
CLS : n% = 9: DIM SHARED val1(2 TO n%) AS INTEGER
FOR i% = 2 TO n%: val1(i%) = 1: NEXT i%: combo& = 1
DO
combo2$ = LTRIM$(STR$(combo&))
c1% = ((combo& \ 10) AND 15) + 1: FOR i% = 1 TO LEN(combo2$): COLOR c1%
PRINT MID$(combo2$, i%, 1); : c1% = c1% + 1: IF c1% > 15 THEN c1% = 1
NEXT i%
val1%(2) = val1%(2) + 1: i% = 2: combo& = combo& * val1%(2) / (val1%(2) - 1)
DO
IF val1%(i%) > i% THEN
IF i% = n% THEN GOTO exitdo2
combo& = combo& \ val1%(i%): val1%(i%) = 1: i% = i% + 1
val1(i%) = val1(i%) + 1: combo& = combo& * val1%(i%) \ (val1%(i%) - 1)
ELSE EXIT DO
END IF
LOOP
LOOP
exitdo2: COLOR 7
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 82
Threads: 1
Joined: Aug 2003
Eh, I'd give it a try, but I'm not too sure what exactly you're doing with it...
LinkMaster Sab
Posts: 3,368
Threads: 195
Joined: Jan 2003
Quote:Eh, I'd give it a try, but I'm not too sure what exactly you're doing with it...
Nothing...er......
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 82
Threads: 1
Joined: Aug 2003
What I meant is, what exactly does it do?
LinkMaster Sab
Posts: 3,368
Threads: 195
Joined: Jan 2003
It does what I said it does..... er.... except in the example I didn't put down what the number turns out to be..
Code:
for i% = 1 to 6
for j% = 1 to 5
for k% = 1 to 4
for l% = 1 to 3
for m% = 1 to 2
print m%*l%*k%*j%*i%
next m%, l%, k%, j%, i%
Except it does this N% times.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,845
Threads: 44
Joined: Aug 2002
What does this program calculate????! Except for 6! of course (n! when using n%).
If you want to calculate n! what are all those innerloops for? Or does it calculate something useful...
Posts: 3,368
Threads: 195
Joined: Jan 2003
run it......
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 82
Threads: 1
Joined: Aug 2003
Ah, I guess I understand it now. I guess I'll give it a shot.
LinkMaster Sab
Posts: 3,368
Threads: 195
Joined: Jan 2003
1) There is a sudden unintended color shift once in a while. I just can't seem to get rid of it. Happens when t3& rolls over. HELP!
EDIT: FIXED. Works great now!
2) Try not to get epileptic seizures while running this program.
EDIT
3) Stand a few feet away and look at what happens on your computer screen. It's more effective that way.
Code:
CLS : SCREEN 13: n% = 5: DIM SHARED val1(2 TO n%) AS INTEGER
a% = 0
c% = 1
e% = 1
t1# = TIMER
FOR i& = 0 TO 31
i3& = i3& + e%
IF i3& = 31 THEN e% = -1 ELSE IF i3& = 0 THEN e% = 1
i4& = i3& * 256 + i3& * 65536: PALETTE i&, i4&: PALETTE 63 - i&, i4&
NEXT i&
DO
b% = (b% - 1) MOD 20
a% = (a% + 2) MOD 10
FOR i% = 2 TO n%: val1(i%) = 1: NEXT i%: combo& = 1
DO: IF INKEY$ <> "" THEN GOTO exitdo2
IF ABS(t1# - TIMER) > .1 THEN
t1# = TIMER
e% = 1
i2& = i2& + c%: i3& = i2&: IF i2& = 30 THEN c% = -1: ELSE IF i2& = 1 THEN c% = 1
FOR i& = 0 TO 31
i3& = i3& + e%
IF i3& = 31 THEN e% = -1 ELSE IF i3& = 0 THEN e% = 1
i4& = i3& * 256 + i3& * 65536: PALETTE i&, i4&: PALETTE 63 - i&, i4&
NEXT i&
END IF
combo2$ = LTRIM$(STR$(combo&))
FOR i% = 1 TO LEN(combo2$)
temp% = VAL(MID$(combo2$, i%, 1))
SELECT CASE i2%
CASE 0: x1% = (x1% + temp%) MOD 320
CASE 1: y1% = (y1% + temp%) MOD 200
CASE 2: line1% = (line1% + temp%) MOD 3
CASE 3: line2% = (line2% + temp%) MOD 3
CASE 4: c1% = (c1% + temp%) MOD 64
LINE (x1% + a%, y1% + b%)-(x1% + a% + line1%, y1% + b% + line2%), c1%
END SELECT
i2% = (i2% + 1) MOD 5
NEXT i%
val1%(2) = val1%(2) + 1: i% = 2: combo& = combo& * val1%(2) / (val1%(2) - 1)
DO
IF val1%(i%) > i% THEN
IF i% = n% THEN GOTO exitdo1
combo& = combo& \ val1%(i%): val1%(i%) = 1: i% = i% + 1
val1(i%) = val1(i%) + 1: combo& = combo& * val1%(i%) \ (val1%(i%) - 1)
ELSE EXIT DO
END IF
LOOP
LOOP
exitdo1:
LOOP
exitdo2: COLOR 7
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 3,368
Threads: 195
Joined: Jan 2003
*cries*
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.