This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 月*/ | |
} |
這題就是找出前兩名必須要90分以上若無就x注意以下測資
3
98 97 97
必須要輸出
98
x
所以要有一個計數器count紀錄印出幾個了
沒有留言:
張貼留言