 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maximum Sum of Products of Two Arrays in C++
In this tutorial, we will be discussing a program to find maximum Sum of Products of Two Arrays.
For this we will be provided with two arrays of same size. Our task is to find the maximum sum by multiplying exactly one element from first element with one element from the second array.
Example
#include<bits/stdc++.h> using namespace std; //calculating maximum sum by //multiplying elements int maximumSOP(int *a, int *b) {    int sop = 0;    int n = sizeof(a)/sizeof(a[0]);    sort(a,a+n+1);    sort(b,b+n+1);    for (int i = 0; i <=n; i++) {       sop += a[i] * b[i];    }    return sop; } int main() {    int A[] = { 1, 2, 3 };    int B[] = { 4, 5, 1 };    cout<<maximumSOP(A, B);    return 0; }  Output
24
Advertisements
 