#include <stdio.h>
void findPairs(int arr[], int size) {
for (int i = 0; i < size - 1; i++) {
for (int j = i + 1; j < size; j++) {
int sum = arr[i] + arr[j];
for (int k = 0; k < size - 1; k++) {
for (int l = k + 1; l < size; l++) {
if (k != i && k != j && l != i && l != j) {
if (arr[k] + arr[l] == sum) {
for (int m = 0; m < size - 1; m++) {
for (int n = m + 1; n < size; n++) {
if (m != i && m != j && m != k && m != l &&
n != i && n != j && n != k && n != l) {
if (arr[m] + arr[n] == sum) {
printf("Person 1: %d, %d\n", arr
[i
], arr
[j
]); printf("Person 2: %d, %d\n", arr
[k
], arr
[l
]); printf("Person 3: %d, %d\n", arr
[m
], arr
[n
]); return;
}
}
}
}
}
}
}
}
}
}
printf("No pairs found with equal sum.\n"); }
int main() {
int arr[] = {13, 26, 39, 52, 65, 78};
int size = sizeof(arr) / sizeof(arr[0]);
findPairs(arr, size);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGZpbmRQYWlycyhpbnQgYXJyW10sIGludCBzaXplKSB7CiAgIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBzaXplIC0gMTsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IGkgKyAxOyBqIDwgc2l6ZTsgaisrKSB7CiAgICAgICAgICAgIGludCBzdW0gPSBhcnJbaV0gKyBhcnJbal07CgogICAgICAgICAgIAogICAgICAgICAgICBmb3IgKGludCBrID0gMDsgayA8IHNpemUgLSAxOyBrKyspIHsKICAgICAgICAgICAgICAgIGZvciAoaW50IGwgPSBrICsgMTsgbCA8IHNpemU7IGwrKykgewogICAgICAgICAgICAgICAgICAgIGlmIChrICE9IGkgJiYgayAhPSBqICYmIGwgIT0gaSAmJiBsICE9IGopIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFycltrXSArIGFycltsXSA9PSBzdW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgbSA9IDA7IG0gPCBzaXplIC0gMTsgbSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgbiA9IG0gKyAxOyBuIDwgc2l6ZTsgbisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtICE9IGkgJiYgbSAhPSBqICYmIG0gIT0gayAmJiBtICE9IGwgJiYgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuICE9IGkgJiYgbiAhPSBqICYmIG4gIT0gayAmJiBuICE9IGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcnJbbV0gKyBhcnJbbl0gPT0gc3VtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJQZXJzb24gMTogJWQsICVkXG4iLCBhcnJbaV0sIGFycltqXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJQZXJzb24gMjogJWQsICVkXG4iLCBhcnJba10sIGFycltsXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJQZXJzb24gMzogJWQsICVkXG4iLCBhcnJbbV0sIGFycltuXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcHJpbnRmKCJObyBwYWlycyBmb3VuZCB3aXRoIGVxdWFsIHN1bS5cbiIpOwp9CgppbnQgbWFpbigpIHsKICAgIGludCBhcnJbXSA9IHsxMywgMjYsIDM5LCA1MiwgNjUsIDc4fTsgCiAgICBpbnQgc2l6ZSA9IHNpemVvZihhcnIpIC8gc2l6ZW9mKGFyclswXSk7CgogICAgZmluZFBhaXJzKGFyciwgc2l6ZSk7CgogICAgcmV0dXJuIDA7Cn0=