Advertisement
Laitofai

BC | Cycle

Dec 13th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, m, a, b, k;
  8.     bool flag=false, check;
  9.     cin>>a>>b;
  10.     for(int i=a; i<=b; i++)
  11.     {
  12.         n=i;
  13.         m=n*n;
  14.         k=0;
  15.         while (n>0)
  16.         {
  17.             if (n%10==m%10)k++;
  18.             m /= 10;
  19.             n /= 10;
  20.             k--;
  21.         }
  22.         if (!k){check=true;}
  23.             else{check=false;}
  24.  
  25.         if(check==true)
  26.         {
  27.             cout<<i<<" ";
  28.             flag=true;
  29.         }
  30.     }
  31.     if(!flag)
  32.         cout<<0<<endl;
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement