@java blue bridge group B Problem Fundamentals cup (30) of 13 questions: Sorting columns
Keywords: array, sort
Problem Description
Given a length n, the number of columns, this number of columns arranged in large ascending order. 1 <= n <= 200
input format
first line an integer n.
The second line contains n integers, the number to be sorted, each of the integer absolute value of less than 10,000.
Output format
output line, the number of columns in ascending order of the sorted output.
Sample input
. 5
. 8. 4. 3. 6. 9
Sample Output
34689
Code:
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int d=s.nextInt();
if(d<1||d>200){
return;
}else{
int[] n=new int[d];
for(int a=0;a<n.length;a++){
n[a]=s.nextInt();
}
s.close();
for(int i=0;i<n.length;i++){ //排序:
int minIndex = i;
for(int j=i;j<n.length;j++){
if (n[j] < n[minIndex]) minIndex = j;
}
int temp=n[minIndex];
n[minIndex]=n[i];
n[i]=temp;
}
for(int a=0;a<n.length;a++){ //输出:
if(n[a]<10000&&n[a]>-10000) System.out.print(n[a]+" ");
}
}
}
}