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
Advancing technology has made life easier for people and businesses today. Imagine that you have to work for an entire day witho
Advocard [28]

Answer:

Sí gracias a la tecnología estamos conectados, hay personas de escasos recursos que no tienen dinero suficiente para poder comprar internet y los niños, se quedan sin estudio, por eso las autoridades deben ayudar a las personas de escasos recursos, espero que te ayude mi comentario, Bendiciones.

Explanation:

3 0
3 years ago
El planeamiento estratégico de una empresa es​
algol13

Answer:

Resultados fiables actualizados diariamente.

Explanation:

7 0
3 years ago
Answer first get branlest
svet-max [94.6K]

Answer:

hii

Explanation:

can i get a brainlist thennnnnn??

7 0
3 years ago
Read 2 more answers
When you download a file from the internet where should you go to find it?.
Gnom [1K]

Answer:

your downloads

Explanation:

6 0
2 years ago
The position of a _____ is a nontechnical position responsible for defining and implementing consistent principles for setting d
Cloud [144]

Answer:

jf

Explanation:

nvfmnv

7 0
3 years ago
Other questions:
  • Clicking on this will minimize all open windows.
    5·2 answers
  • You have implemented a network where each device provides shraed files with all other devices on the network. what type of netwo
    10·1 answer
  • Informatyka klasa 7 daje naj
    10·1 answer
  • The continue statement _________.
    11·1 answer
  • Write code to complete PrintFactorial()'s recursive case. Sample output if userVal is 5:5! = 5 * 4 * 3 * 2 * 1 = 120
    8·1 answer
  • Design state machines to control the minutes and hours of a standard 24 hour clock. Your clock should include an AM/PM indicator
    11·1 answer
  • 1. Why is it important for IT technicians to keep documentation on computers for which they are
    13·1 answer
  • Which type(s) of license(s) allow the underlying software code to be viewed?
    15·1 answer
  • A form of encryption that uses only one key to encrypt and decrypt a file. This is a less
    14·1 answer
  • An array name is a pointer constant because the address stored in it cannot be changed during runtime.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!