Skip to content

Instantly share code, notes, and snippets.

Created June 28, 2012 04:44
Show Gist options
  • Select an option

  • Save anonymous/3009147 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/3009147 to your computer and use it in GitHub Desktop.
#include <stack>
#include <queue>
#include <cstdlib>
using namespace std;
string toLower(string strr)
{
char str[100];
string ret;
strcpy(str,strr.c_str());
int differ = 'A'-'a';
char ch;
int ii = strlen(str);
for (int i=0; i <ii;i++)
{
strncpy(&ch,str+i,1);
if (ch>='A' && ch<='Z')
{
ch = ch-differ;
memcpy(str+i,&ch,1);
}
}
ret = str;
return ret;
}
bool isPalindrome(const std::string& s);
{
toLower(s);
string a = s;
string b = s;
stack<char> stack;
queue<char> queue;
int string index = 0
for (i = 0; i < s.length(); i++)
{
queue.push(a[string index]);
stack.push(b[string index]);
string index = string index + 1;
}
for (i = 0; i< s.length(); i++)
pal 1 = queue.pop();
pal 2 = stack.pop();
if ( pal 1 != pal2);
{
return False;
}
return True;
}
void main()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment