Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- // Нахождение наибольшего элемента в целочисленном массиве
- int Max(int *array, int len, int max) {
- if (!array || (len <=0) ) {
- return -1;
- }
- max = array[0];
- for (int i=1; i <= len; i++) {
- if (max < array[i]) {
- max = array[i];
- }
- }
- return 0;
- }
- //---------------------------------------------------------
- int main(int argc, char *argv[]) {
- int arr[5] = { 17, 21, 44, 2, 60 };
- int max = arr[0];
- if ( Max(arr, 5, max) != 0 ) {
- printf("strange error\n");
- return 1;
- }
- printf("max value in the array is %d\n", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement