1 判断一字符串是不是对称的,如:abccba
2.用递归的方法判断整数组a[N]是不是升序排列
1解答:
bool IsSymmetryStr(char* str)
{
char* pre = str;
char* post = str + strlen(str) - 1;
while (pre < post)
{
if(*pre != *post)
return false;
pre++;
post--;
}
return true;
}
2.解答
bool IsImcreRecuision(int data[],int length)
{
if(length==1)
return true;
if(data[length-2] > data[length-1])
return false;
return IsImcreRecuision(data,length-1);
}