sqStack.cpp
#include <iostream>
#include "Stack.h"
using namespace std;
//利用Stack类判断一个字符串是否为回文串
int main() {
int length;
cout << "输入栈的大小:" << endl;
cin >> length;
Stack<char> s3(length);//CharStack s3(length)
cout << "输入待处理的字符串(输入<代表退一格,输入@代表清楚到行首,输入#结束):";
while (true) {
//从缓冲区挨个读取字符
char ch = getchar();
switch (ch) {
case '<':
s3.pop(); //退格
break;
case '@':
s3.setNULL(); //清除到行首
break;
case '#':
s3.reverseDisplay();
return 0; //直接退出
case '\n':
s3.reverseDisplay();
s3.setNULL();//换行,直接输出
break;
default:
//压入栈内
s3.push(ch)<