Hi,
So now that I've figured out how to seed multiple random numbers, I'm faced with another problem. So basically I have a word (like "Manatee") that I want to jumble up, or mix each letter's position with another. So I have (7) random numbers each between zero and seven. So if "Manatee" is in string
and i have another string
I put characters from word1 using my random numbers as indexes in the second string, with a regularly incremented i. My only problem is that I sometimes have duplicates of my random characters, so i may turn out with: "eaeaMnte"( A true example).
So using this code:
How could I make all my random numbers unique?
-Austen
So now that I've figured out how to seed multiple random numbers, I'm faced with another problem. So basically I have a word (like "Manatee") that I want to jumble up, or mix each letter's position with another. So I have (7) random numbers each between zero and seven. So if "Manatee" is in string
Code:
char word1[7]="Manatee";
Code:
char randWord1[7];
So using this code:
Code:
int n, i;
char word1[7] = "Manatee";
char randWord[7];
for(i=0;i<=strlen(word1);i++){
n = rand() / (RAND_MAX / strlen(word1) + 1);
randWord[i] = word1[n];
}
-Austen
Comment