The specified array contains zero elements that divide the array into subarrays. Calculate the sum of the elements for each of the subarrays and display the result to the user in the format: {subarray elements 1}, sum1 = number; {elements of subarray 2}, sum = number ... 1) How to rebuild what elements of the array would be entered by the user? 2) It is desirable to make it so that the pointer * would be used.
#include <iostream> using namespace std; int main() { const int n(17); int arr[] = {1,4,3,0,8,9,0,1,3,2,0,7,7,7,7,0,1},counter(0); for(int i = 0;i<n;++i){ cout << counter++ << " : "; int sum(0); while(arr[i] && i<n){ cout << arr[i] << ' '; sum += arr[i++]; } cout << "\n" << sum << "\n\n"; } cout << endl; return 0; }