Hey guys, I'm having a bit of trouble with an assignment that has been racking my brain. I'm taking a number from the user, using a function to print its reverse order, checking to see if it is a palindrome in the main program and also removing any leading zero's from the results. I'm having no trouble printing the reverse order but the palindrome check and leading zero removal are driving my crazy. I tried using a loop to check each digit for palindromes but this doesn't seem very effective and returns a reply for each digit for a single statement. Here is the code:
#include<iostream>
using namespace std;
int reverse(int bef[], int &tot)
{
int i,j,t;
for(i=0, j=tot-1; i<j; i++, j--)
{t=bef; bef=bef[j]; bef[j]=t;}
}
int main()
{
int i;
int totdig;
cout << "Enter total number of digits in the number you would like reversed: ";
cin >> totdig;
int before[totdig];
int orig[totdig];
cout << "\nEnter the complete number, seperate each digit with a space: ";
for(i=0;i<totdig;i++) cin >> before;
for(i=0;i<totdig;i++) orig=before;
reverse(before, totdig);
for(i=0;i<totdig;i++) cout << orig;
cout << endl;
for(i=0;i<totdig;i++) cout << before;
cout << endl;
return 0;
}