Untitled
raw download clone
TEXT
views 16
,
size 890 b
#include <fstream>

using namespace std;
ifstream fin("rotund.in");
ofstream fout("rotund.out");
int nc(long long n)
{
    int s = 0;
    while(n)
    {
        s++;
        n/=10;
    }
    return s;
}
int rotund(long long n)
{
    long long p = 1,x=n;
    int nr = nc(n);
    for(int i = 1; i < nr; i++)
        p=p*10;

    for(int i = 1; i < nr;i++)
    {
        x = x%p *10 + x /p;
        if(x==n)
            return 1;
    }
    return 0;
}
int main()
{
    int n,cnt = 0,A[1001];
    long long x;
    fin >> n;
    for(int i =1 ; i<= n; i++)
    {
        fin >> x;
        if(rotund(x)==1)
        {
            A[++cnt] = x;
        }
    }
    if(cnt == 0)
        fout<<0;
        else
        {
            fout<<cnt<<endl;
            for(int i = 1; i <= cnt; i++)
            fout<<A[i]<<" ";
        }


    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.