Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, v[1000], i, j, s1, s2, s = 0, a;
- cin >> n;
- for (i = 0; i < n; i++)
- cin >> v[i];
- for (i = 0; i < n; i++) {
- s1 = 0;
- a = v[i];
- while (a) {
- s1 += a % 10;
- a /= 10;
- }
- for (j = i+1; j < n; j++) {
- s2 = 0;
- a = v[j];
- while (a) {
- s2 += a % 10;
- a /= 10;
- }
- if (s1 == s2)
- s++;
- }
- }
- cout << s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement