Created
February 18, 2026 14:46
-
-
Save rocket-fuel86/960ea9ae5fcc92c41864430bd3197677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| void calcMinMaxArray(int array[], const unsigned int LENGTH, int* max, int* min) | |
| { | |
| *max = array[0]; | |
| *min = array[0]; | |
| for (unsigned int i = 0; i < LENGTH; i++) | |
| { | |
| if (array[i] > *max) | |
| { | |
| *max = array[i]; | |
| } | |
| if (array[i] < *min) | |
| { | |
| *min = array[i]; | |
| } | |
| } | |
| } | |
| int main() | |
| { | |
| const unsigned int LENGTH = 3; | |
| int array[] = { 10, 83, 47 }; | |
| int max = 0, min = 0; | |
| calcMinMaxArray(array, LENGTH, &max, &min); | |
| std::cout << max << ' ' << min << std::endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment