i had submitted this solution to the problem PALIN - The Next Palindrome, but it hasnt been accepted. can anybody help me out here?
include
using namespace std;
bool palin(int);
int main()
{
int arr[10],i,n,m;
cin>>m;
for(i=0;i<m;i++)
{
cin>>arr[i];
}
cout<<"\n";
for(i=0;i<m;i++)
{
n=i;
while (palin(++arr[i])==false);
cout<<arr[i]<<endl;
i=n;
}
return 0;
}
bool palin(int num)
{
int d, check, rev=0;
check=num;
do{
d=num%10;
rev= (rev*10)+d;
num=num/10;
}while(num!=0);
if(check==rev)
return true;
else
return false;
}
created
last reply
- 7
replies
- 3.8k
views
- 7
users
- 2
likes