29.11.2016, 18:20
pawn Код:
ishex(c)
return (('0' <= c <= '9') || ('A' <= toupper(c) <= 'F'));
ColorsInText(const str[])
{
new num, colors;
for(new i = 0, c, d; (c = str[i]) != EOS; i++)
{
if(c == '{')
{
num = 0;
for(d = i + 1; d < i + 7; d++)
{
if(!str[d]) break;
if(!ishex(str[d])) break;
num++;
}
if(num == 6 && str[d] == '}') colors++;
}
}
return colors;
}
pawn Код:
new str[] = "{ASA}Hello {AAAAAA}there {FFFFFF}wazzap {AA}";
printf("Hex codes in text: %d",ColorsInText(str));
