Plz help me on a word scrambling/descrambling thing

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
bobdole
Plz help me on a word scrambling/descrambling thing

Post by bobdole » Mon Jun 27, 2005 7:21 pm

Plz help me with this program I cannot figure out an easy way to have it list all of the combinations of some letters that you put in it. the only way that i can see is if i coded every single combination, which would be really really hard. Plz help me /Thanks.
<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
===============================================
-------------------------------------------------------------------------------------
+++++++++++++++++++++++++++++++++++++++++++++++

Code: Select all

CLS
COLOR 10
LOCATE 4, 22
PRINT "(1-10 ONLY!)"

COLOR 13
LOCATE 6, 22
INPUT "How Many Letters Do You Want"; L%

'IF L% = 1 THEN GOTO one
'IF L% = 2 THEN GOTO two
'IF L% = 3 THEN GOTO three
'IF L% = 4 THEN GOTO four
'IF L% = 5 THEN GOTO five
'IF L% = 6 THEN GOTO six
'IF L% = 7 THEN GOTO seven
'IF L% = 8 THEN GOTO eight
'IF L% = 9 THEN GOTO nine
'IF L% = 10 THEN GOTO ten


LOCATE 1, 22
COLOR 14
PRINT "Put in the letter combination that has "; L%
LOCATE 2, 22
COLOR 3
PRINT "Letters That You would like to Scramble\Descramble."

COLOR 1
LOCATE 10, 6
INPUT "1st Letter "; one$
IF L% = 1 THEN GOTO Scramble


COLOR 3
LOCATE 12, 6
INPUT "2nd Letter "; two$
IF L% = 2 THEN GOTO Scramble


COLOR 5
LOCATE 14, 6
INPUT "3rd Letter "; three$
IF L% = 3 THEN GOTO Scramble


COLOR 6
LOCATE 16, 6
INPUT "4th Letter "; four$
IF L% = 4 THEN GOTO Scramble


COLOR 14
LOCATE 18, 6
INPUT "5th Letter"; five$
IF L% = 5 THEN GOTO Scramble


COLOR 13
LOCATE 20, 6
INPUT "6th Letter"; six$
IF L% = 6 THEN GOTO Scramble


COLOR 1
LOCATE 22, 6
INPUT "7th Letter"; seven$
IF L% = 7 THEN GOTO Scramble


COLOR 2
LOCATE 24, 6
INPUT "8th Letter"; eight$
IF L% = 8 THEN GOTO Scramble


COLOR 3
LOCATE 26, 6
INPUT "9th Letter"; nine$
IF L% = 9 THEN GOTO Scramble



COLOR 4
LOCATE 28, 7
INPUT "10th Letter"; ten$
IF L% = 10 THEN GOTO Scramble



Scramble:
COLOR 10
LOCATE 26
PRINT "1:  "; one$; two$



COLOR 12
LOCATE 28
PRINT "2:  "; one$; two$; three$


COLOR 13
LOCATE 30
PRINT "3:  "; one$; two$; three$; four$


COLOR 11
LOCATE 32
PRINT "4:  "; four$; three$; two$; one$


END

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Tue Jun 28, 2005 12:38 am

You should use an array for that... technically, it's called sorting. ;)

In case you don't know what an array is...

Code: Select all

DIM MyArray(1 to 50) as Integer

For i= 1 to 50
    MyArray(i) = Int(rnd*500)
Next


For i= 1 to 50
    Print MyArray(i)
Next
Arrays would benefit your other program also. ;)
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

bobdole

i dont understand arrays

Post by bobdole » Tue Jun 28, 2005 2:47 am

could you explain how to use an array in my program i can't figure out how i could make the source code that you gave me fit into my program could u plz explain it more in depth /thanks

Mac

Are you sure?

Post by Mac » Tue Jun 28, 2005 5:41 pm

There is one case for one letter: a
There are 1*2 cases for two letters: ab ba
There are 1*2*3 cases for three letters:
abc acb cab bac bca cba
There are 1*2*3*4 cases for four letters
abcd abdc adbc dabc
acbd acdb adcb dacb
cabd cadb cdab dcab
bacd badc bdac dbac
bcad bcda bdca dbca
cbad cbda cdba dcba
etc.
So there are 1*2*3*4*5*6*7*8*9*19 cases for 10 letters.
That's 3,628,800 cases.

You want a program that prints out millions of combinations?

Post Reply