总共15道选择题,3道编程题。我感觉选择题是比较难的。
这是第二道编程题.
我的解法如下(AC):
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {//注意while处理多个case
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int max = Math.max(a,Math.max(b,c));
int min = Math.min(a,Math.min(b,c));
int mid = 0;
int count = 0;
if(a != max && a != min){
mid = a;
}else if(b != max && b != min){
mid = b;
}else{
mid = c;
}
if(mid + 1 == max){
count = (max - min - 1)/2 +1;
}else if((max - mid)%2 == 0){
count += (max - mid)/2;
if((max - min)%2 == 0){
count += (max - min)/2;
}else{
count +=(max - min)/2 + 2;
}
}else if((max - mid)%2 != 0){
count += (max - mid)/2;
if((max - min)%2 != 0){
count += (max - min)/2 +1;
}else{
count += (max - min)/2 +2;
}
}
System.out.print(count);
}
} ```