1、算法要求
回文是指正读反读均相同的字符序列,如“abba”和“abdba”均是回文,但“good”不是回文。写一个算法判定给定的字符序列是否为回文(提示:将一半字符入栈)
2、代码实现
#include <iostream>
#include<stdio.h>
#include<string>
using namespace std;
template <typename ElemType>
struct Stack {
ElemType* items;//元素
int capacity;//容量
int top;//栈顶下标
//int bot;//栈底
Stack(int c = 10)
{
top = 0;
capacity = c;
items = new ElemType[capacity];
}
//判断栈是否为空
void stackEmpty(Stack& s) {
if (s->top == 0