At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Discover in-depth answers to your questions from a wide network of experts on our user-friendly Q&A platform. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.
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.
We hope this was helpful. Please come back whenever you need more information or answers to your queries. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.