Advertisement
OnyRoman

Untitled

Jan 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, v[1000], i, j, s1, s2, s = 0, a;
  7. cin >> n;
  8. for (i = 0; i < n; i++)
  9. cin >> v[i];
  10.  
  11. for (i = 0; i < n; i++) {
  12. s1 = 0;
  13. a = v[i];
  14. while (a) {
  15. s1 += a % 10;
  16. a /= 10;
  17. }
  18. for (j = i+1; j < n; j++) {
  19. s2 = 0;
  20. a = v[j];
  21. while (a) {
  22. s2 += a % 10;
  23. a /= 10;
  24. }
  25. if (s1 == s2)
  26. s++;
  27. }
  28. }
  29. cout << s;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement