Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want the program that takes the string from a text file

What I have tried:

#include<iostream>
using namespace std;
class node{
	public:
	char v;
	node *next;
    node *prev;
};
class queue{
	node *front,*rear;
	int size;
	public:
	queue()
	{
		front=new node();
		rear=NULL;
		size=0;
	}
	void enqueue(char a)
	{
		node *newnode=new node();
		newnode->v=a;
		if(rear!=NULL)
		{
			rear->next=newnode;
			newnode->prev=rear;
			newnode->next=NULL;
			rear=newnode;
		}
		else
		{
			front->next=newnode;
			front->prev=NULL;
			newnode->next=NULL;
			newnode->prev=front;
			rear=newnode;
		}
		size++;
	}
	int si()
	{
		return size;
	}
	int check()
	{
		int count;
		node *p=new node();
		p=front->next;
	    	while(p!=NULL && rear!=NULL)
	    	{
	    		if(p->v==rear->v)
	    		{
	    			count++;
	    		}
	    		p=p->next;
	    		rear=rear->prev;
	    	}
	    	return count;
	    
	}
};
int main()
{
	queue q1;
		int s,num;
	cout<<"Enter size of string :";
	cin>>s;
		char a[s],n;
	cout<<"Enter string :";
	cin>>a;
	for(int i=0;i<s;i++)
	{
		n=a[i];
		q1.enqueue(n);
	}
	
	num=q1.check();
	int ns=s%2;
	if(ns==1)
	{
	if(num==(s-1))
	{
		cout<<"Palindrome"<<endl;
	}
	else
	{
		cout<<"not a Palindrome";
	}
    }
    else
    {
    	if(num==s)
	{
		cout<<"Palindrome"<<endl;
	}
	else
	{
		cout<<"not a Palindrome";
	}
    }
	return 0;
}
Posted
Updated 23-Oct-20 22:13pm
Comments
Sandeep Mewara 24-Oct-20 4:04am    
And your problem is?

1 solution

Then use one of the Input Streams | Microsoft Docs[^] classes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900