import java.util.TreeSet;
public class Test06 {
//整数序列排序找最大值
public static void main(String[] args) {
int[] a= {2,1,-3,6,10,11,10,-5,0};
TreeSet<Integer> treeSet = new TreeSet<>();
for (int i : a) {
treeSet.add(i);
}
int count = 0 ;
for (int integer : treeSet) {
if (count==0){
System.out.println("min: "+integer);
}
count++;
if (count==treeSet.size()){
System.out.println("max: "+integer);
}
}
}
}
public class Test06 {
//整数序列排序找最大值
public static void main(String[] args) {
int[] a = {2,1,-3,6,10,11,10,-5,0};
Arrays.sort(a);
System.out.println("min: "+a[0]+" max: "+a[a.length-1]);
}
}
谁能告诉我为什么用分治思想?
7万+

被折叠的 条评论
为什么被折叠?



