Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int n1, n2, sum1, sum2, c1, nc1, c2, nc2, c3, nc3, kolvo;
- kolvo = 0;
- for (int i = 100000; i <= 999999; i++)
- {
- n1 = i / 1000;
- n2 = i % 1000;
- sum1 = 0;
- sum2 = 0;
- while (n1 != 0)
- {
- sum1 += n1 % 10;
- n1 /= 10;
- }
- while (n2 != 0)
- {
- sum2 += n2 % 10;
- n2 /= 10;
- }
- if (sum1 == sum2)
- {
- n1 = i;
- c1 = n1 % 10;
- n1 /= 10;
- nc1 = n1 % 10;
- n1 /= 10;
- c2 = n1 % 10;
- n1 /= 10;
- nc2 = n1 % 10;
- n1 /= 10;
- c3 = n1 % 10;
- n1 /= 10;
- nc3 = n1 % 10;
- if (((nc1 == nc2) &&(nc2 == nc3)) || ((c1 == c2) && (c2 == c3)))
- {
- kolvo++;
- //cout << i << endl;
- }
- }
- }
- cout << kolvo << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement