Question
please help me fill out the blanks to the prewritten code for c++
1. OBLJ UI SuuenLD, JUN, UML function find MultiMax that finds both the value ane handle ties, the find MultiMax function she
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

int findMultiIndex(int arr[], int n, int *indexMax, int *numberOfMaxIndixes) {

int maxValue = arr[0];

for (int i=0; i<n; i++) {

if (arr[i] > maxValue) {

maxValue = arr[i];

}

}

for (int i=0; i<n; i++) {

if (arr[i] == maxValue) {

indexMax[*numberOfMaxIndixes] = i;

(*numberOfMaxIndixes) ++;

}

}

return maxValue;

}

int main() {

int maxValue;

int indexMax[8] = {-1};

int arr[8] = {3, 2, 3, 4, 1, 4, 2, 4};

int numberOfMaxIndixes = 0;

maxValue = findMultiIndex(arr, 8, indexMax, &numberOfMaxIndixes);

cout << maxValue << endl;

cout << numberOfMaxIndixes << endl;

cout << "Max indices" << endl;

for (int i=0; i<numberOfMaxIndixes; i++) {

cout << indexMax[i] << " ";

}

}

1 2 #include <iostream> using namespace std; clang version 7.0.0-3-ubuntu0.18.04.1 (tags/RELEASE_700/final) ? clang++-7 -pthr

Add a comment
Know the answer?
Add Answer to:
please help me fill out the blanks to the prewritten code for c++ 1. OBLJ UI...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. (40 pts) Consider the following function. Complete the function that does the following: (a) Take...

    1. (40 pts) Consider the following function. Complete the function that does the following: (a) Take three arguments, int array, int as the length of the array, and int *max. (b) Find the maximum value and the minimum value in the array. (c) The pointer max points to the maximum value. (d) Return the pointer that points to the minimum value max)( findMinAndMax(int al l, int length, int int maxValue a[0], minValue al0 int int maxldx 0, minldx 0; for...

  • c++ Some pieces of the following code are missing. Fill in the blanks of the following...

    c++ Some pieces of the following code are missing. Fill in the blanks of the following program. Each answer must fit on a single line. include <iostream> #include <cstdib #include <ctimes using namespace std; randoml_event return 2 (rand() 5 random2 intre + rand 90 return ret: random1_1000X rand) intret 100 return ret: fint 2) return nt; return n2 is oder Is_odot if (n%2 0) return return true; int sum3 (int n, int n, int n3 X int sum= n1 +...

  • in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> //...

    in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> // for string tokenizer and c-style string processing #include <algorithm> // max function #include <stdlib.h> #include <time.h> using namespace std; // Extend the code here as needed class BTNode{ private: int nodeid; int data; int levelNum; BTNode* leftChildPtr; BTNode* rightChildPtr; public: BTNode(){} void setNodeId(int id){ nodeid = id; } int getNodeId(){ return nodeid; } void setData(int d){ data = d; } int getData(){ return data;...

  • C++ Code Pass By Reference Practice Write the following functions for basic array operations based on...

    C++ Code Pass By Reference Practice Write the following functions for basic array operations based on the function descriptions given below. Write the following functions for basic array operations based on the function descriptions given below. FindMinArray: This function will search an array of integers (passed to the function as a parameter) for its minimum value, then return that value. SumArray: This function will sum an array of integers (passed to the function through a parameter) then return that sum....

  • Using C++, fix the following code so that (1) Change the student array storage part so...

    Using C++, fix the following code so that (1) Change the student array storage part so that the data is loaded from a file "students.txt". Use an appropriate data    termination flag. (2) Sort the student array in ascending order of GPA using insertion sort. Print the sorted array (3) Sort the student array in ascending order of ID using insertion sort. Print the sorted array (4) Illustrate Binary search for a particular ID that would be found and one...

  • C++ Look the source code and, 1. the function findMaxVisits is empty and one of its...

    C++ Look the source code and, 1. the function findMaxVisits is empty and one of its parameters does not behave as it should. supply the missing statements and repair the damaged parameter. do not use any non-local constants or variables. 2. the fill function has some errors. repair the function without changing its parameter list. do not use any non-local constants or variables. 3. the show function has some errors. repair the function without changing its parameter list. One error...

  • /// c ++ question plz help me fix this not a new code and explain to...

    /// c ++ question plz help me fix this not a new code and explain to me plz /// Write a function to verify the format of an email address: bool VeryifyEmail(char email[ ]); Do NOT parse the email array once character at a time. Use cstring functions to do most of the work. Take a look at the available cstring and string class functions on cplusplus website. Use a two dimensional array to store the acceptable top domain names:...

  • DO NOT use for loop and while loop Goal: Learn how to use recursive functions. General...

    DO NOT use for loop and while loop Goal: Learn how to use recursive functions. General requirement: Use cout to fully demonstrate your works for all tasks. The output must clearly show how each of these functions work. If no output is displayed for a task below, 0 point will be given to the task. If the output is not clear, some points may be deducted.    Task 1 – Reverse array (3 pts) Given an integer array like: const...

  • please help with the operator overloading lab (intArray) in c++ will provide what it is being...

    please help with the operator overloading lab (intArray) in c++ will provide what it is being required and the code that was given from the book. the code that was provided is below ------------------------------------------------------------------------------------------------------------------------- // iadrv.h #ifndef _IADRV_H #define _IADRV_H #include "intarray.h" int main(); void test1(); void test2(); void test3(); void test4(); void test5(); void test6(); void test7(); void test8(); void test9(); void test10(); void test11(); void test12(); void test13(); void test14(); void test15(); void test16(); void test17(); void test18();...

  • I need help fixing my code: In C++ *************** 1) I want to sum the digits...

    I need help fixing my code: In C++ *************** 1) I want to sum the digits of an n*n matrix 2) find the average I have completed the rest ****Do not use C++ standard library. You must use pointers and pointer arithmetic to represent the matrix and to navigate through it. MY CODE: (I have indicated at which point I need help) #include <iostream> using namespace std; void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT