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
If I wished to insert a hyperlink from text in my document to my company website, what type of link would I insert?
Dmitriy789 [7]

Answer:

the rain hyperlink and water from the ground

Explanation:

5 0
3 years ago
In Windows, which menu allows you to view file characteristics?
Zielflug [23.3K]
A. View Menu
Hope this helps!!! 
6 0
3 years ago
How to move files and folders from desktop in w10?
Oksana_A [137]
Press CTRL + X to cut the file(s) and folder(s) you wish to move from your desktop.

Go to your destination (where you would like to move them to), and press CTRL + V to paste them there.
4 0
3 years ago
You have found statistics on the Internet that you would like to use in your speech.
miss Akunina [59]

Answer:

You cite them correctly and that the statistics are real.

Explanation:

5 0
3 years ago
An application is to be written that would allow students to find out their GPA(double) and their total number of credits (an in
Mama L [17]

Answer:

the key is = rand(the numbers of an integer)

7 0
3 years ago
Other questions:
  • An Open Authorization (OAuth) access token would have a _____ that tells what the third party app has access to
    5·1 answer
  • Select three examples of cryptographs. Security tokens Shared-key Malware Firewalls Message authentication code Public-key
    7·2 answers
  • Which question best addresses the issue of risk with a new job?
    7·2 answers
  • Hacker is a person who illegally breaks into a system or network without any authorization to destroy, steal sensitive data or t
    14·1 answer
  • Write the definitions of two classes Day and Night. Both classes have no constructors, methods or instance variables. Note: For
    8·1 answer
  • Andy, a developer, is designing a new program. Which tool should Andy use to help him complete his task?
    13·1 answer
  • Jemima is reviewing her history report and notices that her headings are not formatted the same throughout the
    7·1 answer
  • A communication medium that carries a large amount of data at a fast speed is called
    6·1 answer
  • JAVA QUESTION::
    10·1 answer
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!