02.09.2014, 13:35
Hi guys, i want to invert a string randomly, example: "hello" - "elhlo" (this totally random), How can i do?
(Sorry for my bad English)
(Sorry for my bad English)
This would actually be quite similar to a card shuffle algorithm actually why not look a few up and see if you can get it to work.
|
RandomizeWord(word[])
{
new tmp;
new r;
for(new i = strlen(word) - 1; i >= 0; i--)
{
r=random(strlen(word));
tmp = word[i];
word[i] = word[r];
word[r] = tmp;
}
}
#include <a_samp>
public OnFilterScriptInit()
{
new word[9];
word = "Computer";
RandomizeWord(word);
printf("%s", word);
return true;
}
RandomizeWord(word[])
{
new tmp;
new r;
for(new i = strlen(word) - 1; i >= 0; i--)
{
r=random(strlen(word));
tmp = word[i];
word[i] = word[r];
word[r] = tmp;
}
}
[16:11:41] Loading filterscript 'comp.amx'... [16:11:41] Cpumeotr