//////////////////////////////
#include<iostream.h>
#include"LinQueue.h"
void main()
{
char ch[10];
for(int i=0;i<10;i++)
cin>>ch[i];
LinQueue MyQueue1,MyQueue2;
MyQueue1.Initialize();
MyQueue2.Initialize();
LinQueue<char> MyQueue1;
LinQueue<char> MyQueue2;
for(int i=0;i<10;i++)
{
MyQueue1(ch[i]);
MyQueue1.JISHUQI();
}
for(int j=10;j>0;j++)
{
//n>>ch;
MyQueue2(ch[i]);
MyQueue2.JISHUQI();
}
for(int k=0;k<10;k++)
{
if(MyQueue1.del()!=MyQueue2.del())cout<<"不是回文数!"<<endl;
return;
}
cout<<"是回文数!"<<endl;
}
/////////////////////////////////////////////////////
头文件:
template<class T>
class LinNode
{
T item;
T *next;
public:
LinNode();
LinNode(const T& item1,const T*ptr);
int *get_next(){return next;}
T get_item(){return item;}
};
template<class T>
class LinQueue
{
T *front;
T *rear;
int count;
LinNode linnode[10];
public:
//LinQueue();
LinQueue(const T &item,LinNode<T> *p);
//void append(const T&item);
T del();
void Initialize(){front=rear=null,count=0;}
void JISHUQI(){count++;}
};
template<class T>
LinNode<T>::LinNode(const T& item1,const T*ptr);
{
item=item1;
next=ptr;
}
template<class T>
LinQueue<T>::LinQueue(const T &item,LinNode<T> *p=NULL):LinNode(item,p)
{
LinNode *p=linnode;
if(rear==null)rear=(LinQueue)p;
if(front==null)front=(LinQueue)p;
rear=LinQueue(p->next);
count++;
}
template<class T>
T LinQueue<T>::del()
{
if(count==0)
{
cout<<"队列已经空"<<endl
exit(0);
}
LinNode *ptr1;
ptr1=(LinNode)front;
front=LinNode(front->next);
ptr1->next=null;
return(ptr1->get_item());
}