Question: Using Cmath and C++ (Visual Studios 2019) We have two arrays of integers, A and B. A and B, each contains exactly N elements. You
Using Cmath and C++ (Visual Studios 2019)
We have two arrays of integers, A and B. A and B, each contains exactly N elements. You should compute the value of S as follows: S=A0*BO + ... + AN-1*BN-1 Write a CH program to fill the two arrays with random integers, then the program will rearrange the numbers in A in such a way that the value of S is as small as possible. You are not allowed to rearrange the numbers in B. The program should output the values stored in both arrays and the computed value of S. Constraints - A will contain between 1 and 50 elements, inclusive. - A and B will contain the same number of elements. - Each element of A will be between 0 and 100, inclusive. - Each element of B will be between 0 and 100, inclusive. Examples: 1) A = {1,1,3) B = {10,30,20) S will be: 80 If you move the number 3 to the beginning of A, you get the minimal possible sum. 2) A= {1,1,1,6,0) B = {2,7,8,3,1) S will be: 18 The best option would be to rearrange the numbers in A this way: (1,1,0,1,6). 3) A = {5,15,100,31,39,0,0,3,26) B = {11,12,13,2,3,4,5,9,1) S will be: 528
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
