#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include"Stack.h"
#include"Queue.h"
using namespace std;
typedef char SElemType;
typedef char QElemType;
void main(char ch1,char ch2){
char str;
int flag = 0;
Stack S; InitStack(S);
Queue Q; InitQueue(Q);
cout << "请输入需要判断是否为回文的字符串" << endl;
Push(S, '\n');
str = getchar();
while (str != '\n'){
Push(S, str); EnQueue(Q, str);
str = getchar();
}
Pop(S, ch1); DeQueue(Q, ch2);
while (ch1 != '\n'){
if (ch1 == ch2) flag = 1;
else{
flag = 0; break;
};
Pop(S, ch1); DeQueue(Q, ch2);
}
if (flag==1)cout << "该字符串为回文!"<< endl;
if (flag==0) cout << "该字符串不是回文!" << endl;
}
The test always execute the "f (flag==0) cout << "该字符串不是回文!" << endl;"!How can I do to put it right?