Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int sizeA = 10;
- const int sizeB = 3;
- int getHighest(int x[]) {
- int result = 0;
- for (int i = 0; i < sizeB; i++)
- {
- if (x[i] >= result) {
- result = x[i];
- }
- }
- return result;
- }
- int getLowest(int x[]) {
- int result = 999;
- for (int i = 0; i < sizeB; i++)
- {
- if (x[i] <= result) {
- result = x[i];
- }
- }
- return result;
- }
- int multSum(int a[], int b[]) {
- int lowest = getLowest(b);
- int highest = getHighest(b);
- int acc = 0;
- for (int i = 0; i < sizeA; i++)
- {
- if (a[i] <= highest && a[i] >= lowest) {
- acc += a[i];
- }
- }
- return acc;
- }
- int main()
- {
- int set1[] = { 5, 2, 3, 8, 1, 6, 4, 12, 9, 10 };
- int set2[] = { 6, 9, 4 };
- cout << multSum(set1, set2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement