Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Search array - Return vector Excercise Write a C++ function that will search a 5 x 5 2Darray of integers. This will be passed as

Search array - Return vector Excercise

Write a C++ function that will search a 5 x 5 2Darray of integers. This will be passed as an argument to that function. The function will return a vector that contains each location of where all of the even numbers are located.

If the array contains no even numbers, the vector will only contain the value -1.

Write a complete C++ program that will demostrate this function working. Output to the console screen a messsage indicating that that array contained no even numbers if this is the case. Alternatively, output to the console screen the loccations of each even numbers (one x and one y coordinate per line).

Making an algorithim before attempting to code this program will be helpful to you.

Example 1:

Array contents ->

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

The contents of the vector will be -> 0,1,0,3,1,1,1,3,2,1,2,3,3,1,3,3,4,1,4,3

Console output:

0 1

0 3

1 1

1 3

2 1

2 3

3 1

3 3

4 1

4 3

Example 2:

Array Contents ->

1 3 5 7 9

1 3 5 7 9

1 3 5 7 9

1 3 5 7 9

1 3 5 7 9

The contents of the vector will be -> -1

Console Output:

This array did not have any even numbers.

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

Students also viewed these Databases questions