andy6804tw
4/9/2017 - 9:18 AM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=15760 這題就是找出前兩名必須要90分以上若無就x注意以下測資 3 98 97 97 必須要輸出 98 x 所以要有一個計數器count紀錄印出幾

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=15760

這題就是找出前兩名必須要90分以上若無就x注意以下測資 3 98 97 97 必須要輸出 98 x 所以要有一個計數器count紀錄印出幾個了

import java.util.*;   
   
public class Main {   
   
  public static void main(String[] args) {   
       Scanner scn = new Scanner(System.in);   
       int n=scn.nextInt(),arr[]=new int[n],count=0;
       for(int i=0;i<n;i++)
    	   arr[i]=scn.nextInt();
       Arrays.sort(arr);
       for(int i=n-1;i>=0;i--){
    	   if(count==2)
    		   break;
    	   else if(arr[i]<90){
    		   System.out.println("x");
    		   count++;
    		   break;
    	   }
    	   else if(arr[i]%2!=0){
    		   continue;
    	   }
    	   else{
    		   System.out.println(arr[i]);
    		   count++;
    	   }
       }
       if(count==1)
    	   System.out.println("x");
  }   
  /*題目:[C_SO37-易] 不誠實不給獎
    作者:1010
    時間:西元 2017 年 4 月*/
}