在eclipse运行后在控制台无法输入数据是怎么回事?
publicclassTestNumsort{publicstaticvoidmain(String[]args){int[]a=newint[args.length];...
public class TestNumsort {
public static void main(String[] args){
int[] a = new int[args.length];
for(int i=0; i<args.length; i++){
a[i] = Integer.parseInt(args[i]);
}
print(a);
selectionSort(a);
print(a);
}
代码如下:
private static void selectionSort(int[] a){
for(int i=0; i<a.length; i++) {
for(int j=i+1; j<a.length; i++){
if(a[j] < a[i]){
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
private static void print(int[] a){
for(int i=0; i<a.length; i++){
System.out.print(a[i]);
System.out.println();
}
}
} 展开
public static void main(String[] args){
int[] a = new int[args.length];
for(int i=0; i<args.length; i++){
a[i] = Integer.parseInt(args[i]);
}
print(a);
selectionSort(a);
print(a);
}
代码如下:
private static void selectionSort(int[] a){
for(int i=0; i<a.length; i++) {
for(int j=i+1; j<a.length; i++){
if(a[j] < a[i]){
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
private static void print(int[] a){
for(int i=0; i<a.length; i++){
System.out.print(a[i]);
System.out.println();
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询