#include"iostream.h"
#include"string.h"
bool palin(char str[], int num);
void main()
{
const int max = 7;
char arr[max] = "abcba";
int top = 0;
if(palin(arr,max))
{
cout<<arr<<" "<<"is 回文数!"<<endl;
}
else
{
cout<<arr<<" "<<"is not 回文数"<<endl;
}
}
bool palin(char str[], int num) //用进栈和出栈是否相等判断是否是回文数
{
int top = 0;
int rear = 0;
char* p = str;
while(*p != '/0')
{
str[top++] = *p++;
}
int j = 0;
for(j = 0; j < num; j++)
{
if(str[--top] == str[rear++])
{
return true;
}
else
{
return false;
}
}
}