19.05.2015, 04:49
Here is better version i made:
On testing, i got the following results:
~~ - false
~r~ - true
~r~~ - false
~~~~ - false (even though the count is even but it have an additional check over that)
pawn Код:
IsSafeGameText(string[])
{
new count;
for(new num, len = strlen(string); num < len; num++)
{
if(string[num] == '~')
{
if((num + 1) < len)
{
if(string[(num + 1)] == '~') return false;
}
count += 1;
}
}
if((count % 2) > 0) return false;
return true;
}
~~ - false
~r~ - true
~r~~ - false
~~~~ - false (even though the count is even but it have an additional check over that)