Any help given would be much appreciated. I normally like to figure things out for myself, but this one has me stumped.
Thanks,
PS I only know basic coding commands, we haven't done extensive work on inbuilt functions and all, so my code will probably look a little, well basic, and that is because that is what I know.
#include <iostream>
#include <String>
using namespace std;
//Function prototype
bool palindrome(string , int , int );
int main()
{
string word;
int b , e;
//call the function.
if (palindrome(word,b,e) == true)
cout<< word << " Is a palindrome." << endl << endl;
else if (palindrome(word,b,e) ==false)
cout << word << " Is not a palindrome." << endl << endl;
system("PAUSE");
return 0;
}
bool palindrome(string test, int b , int e )
{
b = 0;
e = test.size();
if(b >=e)
return true;
if(test[b] != test[e])
return false;
if((test[b])== (test[e]))
{
return palindrome(test,b+1,e-1);
}
return true;
}

New Topic/Question
Reply



MultiQuote





|