I removed that thingy ; and variable a but it still doesn't work.
It is suposed to parse all the words and check if they are palindromes.
I didn't use this method because it is too slow
Since you already have an 'iostream' declaration try to stick to 'couts/cins', makes it easier to debug. Anyway, I have an old code I used for palindrome testing using stacks to hold the values, hope it helps a little. I've not done this in quite long, so I can't remember most of what to do, sorry I could not be of more help.
#include <iostream>
#include <stack>
usingnamespace std;
int main()
{
stack<char>mystack,tempstack,reversestack;
int k;
mystack.push('C');
mystack.push('I');
mystack.push('V');
mystack.push('I');
mystack.push('C');
cout <<"The size is: "<<mystack.size()<<endl;
cout << "The word is: ";
while (!mystack.empty())
{
cout << " " << mystack.top();
k=mystack.top();
mystack.pop();
reversestack.push(k);
tempstack.push(k);
}
cout <<endl<<"The reverse word is: ";
while (!tempstack.empty())
{
cout << " " << tempstack.top();
k=tempstack.top();
tempstack.pop();
mystack.push(k);
}
if(reversestack==mystack)
cout<<endl<<"It is a palindrome!";
else
cout<<endl<<"It is not a palindrome!";
return 0;
}
You didin't understand me well.
Standard input is a sentence Example: "My name on www.cplusplus.com is aarmin."
The program is suposed to parse all the words and check if they are palindromes and write number of palindromes on standard output.
Palindrom in this example sentence is "www".
You can see that i removed all character except numbers and letters so "www" is a palindrom. if (isalnum(rec[i]))
I DON'T WANT to use this code because it can't pass some tests because it is to slow.