AcWing 818. 数组排序 - Java
原题链接
困难
作者:
KYCygni
,
2021-03-28 12:24:33
,
所有人可见
,
阅读 436
Java 代码
import java.util.Scanner;
public class Main
{
public static void sort(int[] nums, int start, int end)
{
for (int i = start; i <= end; i ++)
{
for (int j = i; j <= end; j ++)
{
if (nums[i] > nums [j])
{
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
}
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int s = cin.nextInt();
int l = cin.nextInt();
int r = cin.nextInt();
int[] nums = new int[s];
for (int i = 0; i < s; i++)
nums[i] = cin.nextInt();
sort(nums, l, r);
for (int i = 0; i < nums.length; i ++)
System.out.print(nums[i] + " ");
}
}