Write a function checkConditions that takes a two-dimensional array of integers, array, and a set of integers, conditions, as input. The function should return 0 if all elements in the array are contained in the conditions set. If any element in the array is not in the conditions set, the function should return -1. Function signature: int checkConditions(int array[][], int rowSize, int colSize, std::set conditions) Write the implementation of the function checkConditions without using any built-in functions for searching elements in sets. You should implement your own algorithm for searching elements in the conditions set. Example: int arr[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; std::set conditions = {1,2,3,6,7,8}; int result = checkConditions(arr, 3, 4, conditions); //result will be 0 since all elements in the array are in the conditions set.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.4: Passing Addresses
Problem 4E
icon
Related questions
Question

Write a function checkConditions that takes a two-dimensional array of integers, array, and a set of integers, conditions, as input. The function should return 0 if all elements in the array are contained in the conditions set. If any element in the array is not in the conditions set, the function should return -1.

Function signature: int checkConditions(int array[][], int rowSize, int colSize, std::set<int> conditions)

Write the implementation of the function checkConditions without using any built-in functions for searching elements in sets. You should implement your own algorithm for searching elements in the conditions set.

Example: int arr[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; std::set<int> conditions = {1,2,3,6,7,8}; int result = checkConditions(arr, 3, 4, conditions); //result will be 0 since all elements in the array are in the conditions set.

Expert Solution
steps

Step by step

Solved in 7 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr