d074: 電腦教室

題目:http://zerojudge.tw/ShowProblem?problemid=d074

程式碼:

import java.util.Scanner;
public class d074 {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int max;
            int [] arr = new int[n];
            for(int i=0;i<n;i++){ //輸入儲存陣列
             arr[i] = sc.nextInt();
             
            }
            max = arr[0];
            for(int i=1;i<arr.length;i++){
             if(arr[i]>=max){
              max = arr[i]; 
              
             }
            }
            System.out.println(max);
            
            
        }

 }

}

留言

熱門文章