除夕之时祝大家新年快乐!!!还有个问题要问问
好学达人 2014-01-30 05:19:51
我下面的代码是递归吗?
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
bool testPalindrome ( char a[], int size );
int main()
{
char array[] = "a man a plan a canal panama";
int size = sizeof ( array );
bool k;
k = testPalindrome ( array, size );
if ( k )
cout << "字符串是回文" << endl;
else
cout << "字符串不是回文" << endl;
cout << endl;
return 0;
}
bool testPalindrome ( char a[], int size )
{
static int start = 0;
static int end = size - 2;
while ( ! ( a[ start ] > 65 && a[ start ] < 90 || a[ start ] > 97 && a[ start ] < 122 ) )
start++;
while ( ! ( a[ end ] > 97 && a[ end ] < 122 || a[ end ] > 65 && a[ end ] < 90 ) )
end--;
if ( a[ start ] == a[ end ] && start <= end )
{
start++;
end--;
testPalindrome ( a, size );
return true;
}
else
return false;
}