carrie wrote:
please help me!!
Carrie, it might be more helpful to us if we had a better understanding of the problem at hand. My interpretation of your dire straights is that you need some code to scramble a word. Does it matter how long the word is?
Here's what I suggest you do...
1)have the user input the word to a string var
2)figure out the length of the string var using the length function
3)take apart the string var using substrings
4)at random put the individual characters back together to form a garbled word.
code: |
var word : string
get word
var wordLength : int
wordLength := length (word)
var words : array 1 .. wordLength of string
for i : 1 .. wordLength
words (i) := word (i .. i)
end for
var x, y: int
var temp:string
for i : 1 .. 10
for j : 1 .. wordLength
x := Rand.Int (1, wordLength)
y := Rand.Int (1, wordLength)
temp := words (x)
words (x) := words (y)
words (y) := temp
end for
end for
|