CODE USING C++ 4. Find the Elephant by CodeChum Admin When dealing with problems, it is always best to find the "elephant" in the room. The elephant is basically the biggest issue. Once this is resolved, it's almost always easier to move forward. As a therapist, I know how to find the elephant in the room. However, I'm feeling sick today and the next client is coming. Could you please find the elephant for me? Instructions: In the code editor, you are provided with a function, findElephant() that accepts a 2D array and returns the largest element in the array. This function has already been implemented so do not edit this. You are also provided with the 2D array in the main() function. Your only task is to call the findElephant() function and pass the 2D array, and print the return value. Output Elephant:·10 EDIT THIS CODE: #include #include using namespace std; int findElephant(int[][100]); int main(void) { int matrix[100][100] = { {1, 3, 33, 109, 2, 65, 32, 28, 129, 75}, {2, 44, 59, 8, 231, 632, 55, 205, 98, 1}, {76, 2, 321, 16, 209, 65, 12, 167, 259, 29}, {0, 103, 99, 3, 2, 65, 32, 321, 53, 75}, {44, 264, 50, 7, 142, 65, 100, 28, 98, 33}, {87, 22, 99, 67, 22, 412, 99, 502, 52, 24}, {91, 93, 233, 101, 330, 65, 98, 28, 98, 76}, {12, 65, 59, 99, 2, 65, 32, 333, 10, 88}, {3, 24, 101, 331, 542, 65, 32, 239, 338, 175}, {76, 3, 59, 21, 229, 65, 32, 28, 98, 75}, }; return 0; } // NOTE: DO NOT EDIT THIS FUNCTION int findElephant(int arr[][100]) { int largest = INT_MIN; for(int row = 0; row < 100; row++) { for(int col = 0; col < 100; col++) { if(arr[row][col] > largest) { largest = arr[row][col]; } } } return largest;
CODE USING C++
4. Find the Elephant
by CodeChum Admin
When dealing with problems, it is always best to find the "elephant" in the room. The elephant is basically the biggest issue.
Once this is resolved, it's almost always easier to move forward.
As a therapist, I know how to find the elephant in the room. However, I'm feeling sick today and the next client is coming. Could you please find the elephant for me?
Instructions:
- In the code editor, you are provided with a function, findElephant() that accepts a 2D array and returns the largest element in the array. This function has already been implemented so do not edit this.
- You are also provided with the 2D array in the main() function.
- Your only task is to call the findElephant() function and pass the 2D array, and print the return value.
Output
#include <iostream>
#include <climits>
using namespace std;
int findElephant(int[][100]);
int main(void) {
int matrix[100][100] = {
{1, 3, 33, 109, 2, 65, 32, 28, 129, 75},
{2, 44, 59, 8, 231, 632, 55, 205, 98, 1},
{76, 2, 321, 16, 209, 65, 12, 167, 259, 29},
{0, 103, 99, 3, 2, 65, 32, 321, 53, 75},
{44, 264, 50, 7, 142, 65, 100, 28, 98, 33},
{87, 22, 99, 67, 22, 412, 99, 502, 52, 24},
{91, 93, 233, 101, 330, 65, 98, 28, 98, 76},
{12, 65, 59, 99, 2, 65, 32, 333, 10, 88},
{3, 24, 101, 331, 542, 65, 32, 239, 338, 175},
{76, 3, 59, 21, 229, 65, 32, 28, 98, 75},
};
return 0;
}
// NOTE: DO NOT EDIT THIS FUNCTION
int findElephant(int arr[][100]) {
int largest = INT_MIN;
for(int row = 0; row < 100; row++) {
for(int col = 0; col < 100; col++) {
if(arr[row][col] > largest) {
largest = arr[row][col];
}
}
}
return largest;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images