JAVA 7.10

  1. import java.util.Scanner;
  2. public class Findlargest {
  3.     public static void main(String[] args) {
  4.         int i;
  5.         int []iBucket = new int [10];
  6.         Scanner input =  new Scanner(System.in);
  7.         for ( i=0 ; i<10 ; i++ )
  8.             iBucket[i] = input.nextInt();
  9.         System.out.println(FindL(iBucket));
  10.     }
  11. // method find largest
  12.     public static int FindL (int[] array )
  13.     {
  14.     int Temp;   // find largest
  15.     int j;
  16.     Temp = -1;
  17.     for ( j=0 ; j<10 ; j++ )
  18.         {
  19.         if (array[j] > Temp )
  20.             Temp = array[j];
  21.         }
  22.     return Temp;
  23.     }
  24. }


Find the largest element in the array

留言

這個網誌中的熱門文章

Codeforces --- string task

Uva 674 ---- coin change

codeforces 271A --- beautiful year