原题
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=3&problemid=10
- 本题主要考验排序问题,java会简单很多,但还是重新写了个“轮子”。即代码中可替换部分。
源码
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int c = in.nextInt(), temp, input;
for (int j = 0; j < c; j++) {
int n = in.nextInt();
int[] dates = new int[n];
for (int i = 0; i < n; i++) {
input = in.nextInt();
//替换代码
for(int k = 0;k < i;k++){
if(input < dates[k]){
temp = dates[k];
dates[k] = input;
input = temp;
}
}
dates[i] = input;
}
//替换代码
//Arrays.sort(dates);
System.out.println(dates[1]);
}
}
}