d984: 棄保效應
題目:http://zerojudge.tw/ShowProblem?problemid=d984
程式碼:
程式碼:
import java.util.Arrays;
import java.util.Scanner;
public class d984 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
long a = sc.nextLong();//候選人a
long b = sc.nextLong();//候選人b
long c = sc.nextLong();//候選人c
long [] arr = new long[3];//儲存陣列
arr [0] = a;
arr [1] = b;
arr [2] = c;
Arrays.sort(arr);//排序
long unknow = (arr[0]+arr[1] > arr[2])? arr[1]:arr[2];//把比較結果傳入
if(unknow == a) {
System.out.println("A");
} else if(unknow == b) {
System.out.println("B");
} else {
System.out.println("C");
}
//int 不行會有益位
}
}
}

留言
張貼留言