求一个用队列判断回文的程序c++的,简单易懂最好

来源:百度知道 编辑:UC知道 时间:2024/06/14 09:33:04
千万别用c我看不懂滴~~~
呵呵
本人有点笨啊
作业都不会写啊
要用队列的咧

你指字符串的回文吗?

#include <iostream>
using namespace std;

int ispalindrome(char str[]){
int i=0;
while(str[i]!='\0') i++;
i--;
int j=0;
while(j<i){
if(str[j]!=str[i]) return 0;
j++;
i--;
}
if(j>=i) return 1;
}

int main(){
char str[100];
cout<<"Enter the string: ";
cin>>str;
if(ispalindrome(str)) cout<<"This string is a palindrome."<<endl;
else cout<<"This string is not a palindrome."<<endl;
}

#include<stdio.h>

#define MAXN 26
typedef char QueueEntry;
typedef struct queue{

int front;
int rear;
QueueEntry entry[MAXN];
}Queue;

void Creat_queue(Queue* q)
{
q->front=-1;
q->rear=-1;
}

int en_queue(Queue* q,char x)

{

if(q->rear==MAXN-1)