This function needs to check if the sting is a polynomial .

It check it for some sort pattern. If this string is not builded by this pattern then it return

0. else it returns 1

i translated this function from java

can you tell me what pattern it checks in this string??

(variable length is the length of the string)

Code:

int checkPoly(char[] str,int length)
{
int result;
result=false;
int index;
int index2;
int index3;
for( index=0;((index<length)&& (((str[length-1]>'0')&&(str[length-1]<'9')))));index++)
{
if((str[index]=='(')&&(str[index+1]!='('))
{
for (index2=0;index2<length;index2++)
{
if(str[index2]==')')
{
if((str[index2+1]=='x')&&(str[index2+2]=='^')&&((str[index2+3]>'0')&&(str[index2+3]<'9'))))
{
result=1;
index=length;
for (index3=index2+2;((index3<length)&&(((length)-(index3+2)!=0)));index3++)
{
if(str[index3]=='(')
{
if(str[index3-1]=='+')
{
index3=length;
result=1;
}
else
{
index3=length;
index2=length;
result=0;
}
}else{}
}
}else
{
result=0;
index2=length;
index=length;
}
}else{}
}
}else {
result=0;
index=length;
}
}
return result;
}