23.06.2010, 18:37
Your example has a lot of unneeded stuff.
Also, the 'ultimate' version would be this
Also, the 'ultimate' version would be this
pawn Код:
IsNumeric(const string[])
{
if (!strval(string))
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] != '0') return 0;
}
}
return 1;
}
pawn Код:
printf("%d\n", IsNumeric("0000")); //returns 1
printf("%d\n", IsNumeric("2341")); //returns 1
printf("%d\n", IsNumeric("+2341")); //returns 1
printf("%d\n", IsNumeric("-2341")); //returns 1
printf("%d\n", IsNumeric("jhb342u")); //returns 0