Advertisement
ZiGGi

abc * abc = defbc

Nov 7th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int bufer = 0;
  10.     int a, b, c, _b, _c, _d, _e, _f;
  11.  
  12.     for (a = 0; a < 10; a++)
  13.     {
  14.         for (b = 0; b < 10; b++)
  15.         {
  16.             if (a == b) continue;
  17.  
  18.             for (c = 0; c < 10; c++)
  19.             {
  20.                 if (b == c) continue;
  21.  
  22.                 bufer = a*100 + b*10 + c;
  23.                 bufer *= bufer;
  24.                 if (bufer > 99999)
  25.                 {
  26.                     continue;
  27.                 }
  28.                 // abc * abc = defbc
  29.                 _c = bufer % 10;
  30.                 _b = bufer / 10 % 10;
  31.                 _f = bufer / 100 % 10;
  32.                 _e = bufer / 1000 % 10;
  33.                 _d = bufer / 10000;
  34.                 if (b == _b && c == _c)
  35.                 {
  36.                     if (c != b &&
  37.                         _b != _c && _b != _f && _b != _e && _b != _d &&
  38.                         _c != _f && _c != _e && _c != _d &&
  39.                         _f != _e && _f != _d &&
  40.                         _e != _d)
  41.                     {
  42.                         printf("result = %d\n", (int)sqrt(bufer));
  43.                     }
  44.                 }
  45.             }
  46.         }
  47.     }
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement