Resource limit time limit: 1.0s memory limit: 512.0MB
Problem description Given a sequence of length n, arrange this sequence in ascending order. 1<=n<=200
The input format
of the first conduct an integer n.
The second line contains n integers, which are the numbers to be sorted, and the absolute value of each integer is less than 10000.
The output format outputs one row, and the sorted number sequence is output in ascending order.
Sample input
5
8 3 6 4 9
Sample output
3 4 6 8 9
public class Main {
public static void main(String[] args) {
int n=5;
int []nums= {
8,3,6,4,9};
sort(n,nums);
for(int k=0;k<nums.length;k++) {
System.out.print(nums[k]);
}
}
public static void sort(int n,int[] nums) {
int temp=0;
for(int i=0;i<nums.length;i++) {
for(int j=0;j<nums.length;j++) {
if(nums[i]<nums[j]) {
temp=nums[j];
nums[j]=nums[i];
nums[i]=temp;
}
}
}
}
}