57.0k views
1 vote
Find the maximum and minimum of an array of size ten​

User YwH
by
4.2k points

1 Answer

2 votes

Answer:

// Naive solution to find the minimum and maximum number in an array. public static void findMinAndMax(int[] A) ...

int max = A[0]; int min = A[0];

// do for each array element. for (int i = 1; i < A. ...

if (A[i] > max) { max = A[i]; ...

else if (A[i] < min) { ...

System. ...

{ ...

// find the minimum and maximum element, respectively.

User Vishu
by
4.0k points