1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
7nadin3 [17]
3 years ago
10

In this question, you must create a function in C++ using an external editor. When satisfied with your work, you shall attach it

here for full credit. All your source code must be in one cpp file. Write a function that accepts two parameters, the first shall be an array of integers, and the second shall be the length of the input array. The function you create shall process the input array and calculate if multiplying any two numbers within produces a result also contained in the array. If the product of two number equals a third contained in the array, the function shall return true (1). Otherwise, the function shall return 0. For example, array: [0,1,3,5,15], the function shall return True, for 3x5=15. array: [0,1,3,3,7], the function shall return True, for 1x3=3. (duplicates are possible) array: [2,-4,-3,10,8], the function shall return False array: [6,4,-3,-2,0,5], the function shall return True, for -3x-2=6 Do not assume well-formed input, so you must include some basic error checking. You may use the header files contained in the standard library and are encouraged to use data structures (like a map or set) to complete the problem efficiently
Computers and Technology
1 answer:
RideAnS [48]3 years ago
6 0

Answer:

See explaination

Explanation:

#include<iostream>

#include<map>

using namespace std;

bool contains(int arr[], int size){

map<int,int> nums;

for(int i=0; i< size; i++) nums[arr[i]]=1;

int product;

for(int i=0; i<size-1; i++){

for(int j=i+1;j<size;j++){

product = arr[i]*arr[j];

if (nums[product]==1) return true;

}

}

return false;

}

int main(){

int arr[] ={6,4,-3,-2,0,5};

cout<<boolalpha <<contains(arr,5)<<endl;

return 0;

}

You might be interested in
How long can a lightning last
Maru [420]
A lightning can last 30 microseconds.
8 0
4 years ago
Which of the following is document content that displays at the top of every page?
Vlad1618 [11]

Answer: Header/Title

Explanation:

4 0
3 years ago
How to get amount after a percentage increase in excel​
Tresset [83]

Answer:

First: work out the difference (increase) between the two numbers you are comparing.

Increase = New Number - Original Number.

Then: divide the increase by the original number and multiply the answer by 100.

% increase = Increase ÷ Original Number × 100.

Explanation:

3 0
2 years ago
Read 2 more answers
Sarah needs help with a presentation that she is giving the next day. What are the best ways for her to share her work to get im
Papessa [141]

Answer:

Office365 with PowerPoint Online comment accessibility.

7 0
3 years ago
Read 2 more answers
How many performance steps are involved in the process of completing a detainee?
Reika [66]
It looks like you've posted your question in wrong topic. Anyway I can help you. Performance steps for Guard Detainees and Completing a detainee are almost the same. If my memory serves me well, there are 6 performance steps. But the main rule is to be patient and ready for action. Always prepare your weapons to use, check if they are functional.
6 0
3 years ago
Other questions:
  • Think about the last business that you purchased a product or a service from. What three types of software might they need? Why
    15·2 answers
  • Many of the internal OS services are provided by the ___________ module, which contains the most important operating system proc
    8·1 answer
  • A database administrator (DBA) must have a clear understanding of the fundamental business of an organization, be proficient in
    11·1 answer
  • What is the grooming process as it relates to online predators?
    12·2 answers
  • A database record can best be described as:
    11·1 answer
  • Which of the following representations in two's complement notation represents the largest value?
    12·2 answers
  • What Does S.T.E.M stand for?​
    8·1 answer
  • What is extraction, transformation, and loading? Group of answer choices It is a process of entering data, tracking data, and lo
    5·1 answer
  • Amber wants to give her audience copies of her presentation so they can follow along and take notes. What option should Amber ch
    9·2 answers
  • Which attributes does not come in tag?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!