#include <iostream.h>
#include <stdlib.h>
   int number = 0;
   char outstring[100];
   bool palindrome = true;

int getNumberFromString(char *in)
   {
   int sum = 0;
   while(*in != 0)
      {
      sum = sum*10+(*in - '0');
      in++;
      }
   return sum;
   }

char * turnNumberToBase(int target, int base)
   {
   int length = 0;
   char instring[100];
   char *in;
   in = &instring[0];
   char *out;
   out = &outstring[0];
   while(target != 0)
      {
      length++;
      if(target%base > 9)
         *in = target%base+ '7';
      else
         *in = target%base + '0';
      in++;
      target = target/base;
      }
   *in = 0;
   in = &instring[0];
   for(int x = length-1; x >=0; x--)
      {
      *out = *(in+x);
      out++;
      }
   *out = 0;
   out = &outstring[0];
   while(*in != 0)
      {
      if(*in != *out)
         palindrome = false;
      in++;
      out++;
      }
   out = &outstring[0];
   return out;
   }

bool validString(char *in)
   {
   while(*in != 0)
      {
      if(*in < '0' || *in > '9')
         return false;
      in++;
      }
   return true;
   }

int main()
   {
   char numString[100];
   cout << "Enter number: ";
   cin >> numString;
   if(!validString(numString))
      {
      cout << "Please enter a valid number, and stop messing around. " << endl << endl << endl;
      exit(0);
      }
   number = getNumberFromString(numString);
   for(int x = 2; x <17; x++)
      {
      palindrome = true;
      char *pointer;
      pointer = turnNumberToBase(number, x);
      cout << "Base " << x << ": ";
      while(*pointer != 0)
         {
         cout << *pointer;
         pointer++;
         }
      if(palindrome)
         cout << "   is a Palindrome.";
      cout << endl;
      }
   cout << endl << endl;
   }