Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define N 100001
- using namespace std;
- ifstream fin("date.in");
- struct node
- {
- char key;
- node *next;
- };
- node*l;
- void AddLast(node*&l, char x)
- {
- node*q=new node;
- q->key=x;
- q->next=NULL;
- if(l==NULL)l=q;
- else
- {
- node*p;
- for(p=l; p->next!=NULL; p=p->next);
- p->next=q;
- }
- }
- void AddFirst(node*&p, char x)
- {
- node*q=new node;
- q->key=x;
- q->next=p;
- p=q;
- }
- bool palindrom(node *l)
- {
- node*l2=NULL,*q,*p;
- for(q=l; q; q=q->next)
- AddFirst(l2,q->key);
- for(p=l,q=l2; p!=NULL &&q!=NULL; p=p->next,q=q->next)
- if(p->key!=q->key)return 0;
- return 1;
- }
- void Citire(node* &l)
- {
- char x;
- while(fin>>x)
- AddLast(l,x);
- }
- int main()
- {
- Citire(l);
- cout<<palindrom(l);
- return 0;
- }
Add Comment
Please, Sign In to add comment