Untitled

 avatar
unknown
plain_text
2 years ago
715 B
9
Indexable
#include<iostream>
using namespace std;
int n,a[10],ans;
int joft(int i)
{
    return n-(i-1);
}
bool check()
{
    for(int i=1;i<=n;i++)
        if(a[i]!=a[joft(i)])
            return false;
    return true;
}
bool pal(int x)
{
    n=0;
    while(x)
    {
        n++;
        a[n]=x%10;
        x/=10;
    }
    return check();
}
bool pal2(int x)
{
    int y=0,copyx=x;
    while(x)
    {
        y*=10;
        y+=x%10;
        x/=10;
    }
    return (y==copyx);
}
int main()
{
    for(int a=100;a<1000;a++)
        for(int b=100;b<1000;b++)
        {
            int c=a*b;
            if(pal(c) && c>ans)
                ans=c;
        }
    cout<<ans<<endl;
}
Editor is loading...