Current Output :
5 Level 5 --A palindrome
Madam --A palindrome
ABBA --A palindrome
Able was I ere I saw elba --A palindrome
A Man, A Plan A Panama Canal --A palindrome
Palindrome--A palindrome
a&% $#()+@ V$)(* A --A palindrome
Right Output:
5 Level 5 --A palindrome
Madam --A palindrome
oppo --A palindrome
Able was I ere I saw elba --A palindrome
BABE --A palindrome
Palindrome--Not a palindrome
a&% $#()+@ V$)(* A --A palindrome
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char str[80];
int len = 0;
bool isPalindrome=true;
fstream myfile;
myfile.open("C:\\George.txt");
while(! myfile.eof())
{
myfile.getline(str,80);
for(int i = 0; i <= len; i++)
{
if (str[i] != str[len- i])
{
isPalindrome=false;
break;
}
if(isPalindrome)
cout<<str<< "--A palindrome.\n";
else cout <<str<< "--Not a palindrome.\n";
i++; //This doesn't work...
}
}
system("Pause");
return 0;
}
This post has been edited by jimblumberg: 11 October 2012 - 09:15 AM
Reason for edit:: Fixed Code tags.

New Topic/Question
Reply



MultiQuote






|