Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

Students also viewed these Databases questions

Question

=+ What topics are contained in the contracts?

Answered: 1 week ago

Question

=+Are they specific or general in nature?

Answered: 1 week ago

Question

=+ What is the nature of the contracts or agreements with unions?

Answered: 1 week ago