IDNLearn.com helps you find the answers you need quickly and efficiently. Find the solutions you need quickly and accurately with help from our knowledgeable community.
Sagot :
Answer:
#include <iostream>
using namespace std;
void fragment(int arr[], int n){
for (int i = 0; i < n; i++){
for (int x = 0; x < n; x++){
if (x != i && arr[i] + arr[x] == 0){
cout<< arr[i] << " , " << arr[x];
}
}
}
}
int main(){
int n = 7;
int myArr = {1, 2, -1, -2, 0, 0, 3};
fragment(myArr, n);
}
Explanation:
The C++ source code defines an array called "myArr" in the main program and its array size n. The void function "fragment" prints out the pairs of the array whose sum equates to zero.
Thank you for contributing to our discussion. Don't forget to check back for new answers. Keep asking, answering, and sharing useful information. Your questions deserve precise answers. Thank you for visiting IDNLearn.com, and see you again soon for more helpful information.