Question: c++ program Given an unsorted array Aof size Nof non-negative integers, find a continuous sub-array which adds to the given number. Declare dynamic arrays and

c++ program

Given an unsorted array Aof size Nof non-negative integers, find a continuous sub-array which adds to the given number. Declare dynamic arrays and use only pointers syntax (no [ ]s or (ptr+i) stuff and no break statements. To delete a dynamic array, delete[] ptr.

Input will be the number of input values to enter followed by the sumto compare with. Print out the continuous sub-array of values that are equal to sum or the message No sum found. There may be more than one sub-array to be found in a given input so print out all continuous sums.

Example:

Input: 6 10 First number represents 6 values to enter and 10 is the sum.

3 5 8 2 3 5 6 input values for the array.

Output: 8 2 and 2 3 5 these are continuous sub-array/slice of array values that sum to 10

Your input data sets: I would create an input file for the following.

6 10

3 5 8 2 3 5

8 20

5 10 3 3 10 3 4 14

11 19

8 5 3 3 7 6 5 1 7 2 4

9 15

3 8 4 3 10 2 3 8 2

6 12

8 5 3 3 4 5

30 20

10 12 8 5 15 5 10 8 2 4 6 9 1 7 6 3 2 7 2 18 20 5 2 2 7 9 2 3 15 5

30 19

4 2 4 3 6 2 1 5 3 2 4 7 1 3 4 1 3 3 1 5 2 1 5 1 4 2 2 2 3 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!