Advertisement
bghj25

Untitled

Nov 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n1, n2, sum1, sum2, c1, nc1, c2, nc2, c3, nc3, kolvo;
  6.     kolvo = 0;
  7.     for (int i = 100000; i <= 999999; i++)
  8.     {
  9.         n1 = i / 1000;
  10.         n2 = i % 1000;
  11.         sum1 = 0;
  12.         sum2 = 0;
  13.         while (n1 != 0)
  14.         {
  15.             sum1 += n1 % 10;
  16.             n1 /= 10;
  17.         }
  18.         while (n2 != 0)
  19.         {
  20.             sum2 += n2 % 10;
  21.             n2 /= 10;
  22.         }
  23.         if (sum1 == sum2)
  24.         {
  25.             n1 = i;
  26.             c1 = n1 % 10;
  27.             n1 /= 10;
  28.             nc1 = n1 % 10;
  29.             n1 /= 10;
  30.             c2 = n1 % 10;
  31.             n1 /= 10;
  32.             nc2 = n1 % 10;
  33.             n1 /= 10;
  34.             c3 = n1 % 10;
  35.             n1 /= 10;
  36.             nc3 = n1 % 10;
  37.             if (((nc1 == nc2) &&(nc2 == nc3)) || ((c1 == c2) && (c2 == c3)))
  38.  
  39.             {
  40.                 kolvo++;
  41.                 //cout << i << endl;
  42.             }
  43.         }
  44.     }
  45.     cout << kolvo << endl;
  46.     system("pause");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement