JAVA 7.10
- import java.util.Scanner;
- public class Findlargest {
- public static void main(String[] args) {
- int i;
- int []iBucket = new int [10];
- Scanner input = new Scanner(System.in);
- for ( i=0 ; i<10 ; i++ )
- iBucket[i] = input.nextInt();
- System.out.println(FindL(iBucket));
- }
- // method find largest
- public static int FindL (int[] array )
- {
- int Temp; // find largest
- int j;
- Temp = -1;
- for ( j=0 ; j<10 ; j++ )
- {
- if (array[j] > Temp )
- Temp = array[j];
- }
- return Temp;
- }
- }
Find the largest element in the array
留言
張貼留言