Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Test {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int k = sc.nextInt();
- sc.close();
- int[] a = new int[] {9, 1, 7, 6, 5, 6, 8, 9};
- if (k > a.length) {
- System.out.println("Invalid");
- return;
- }
- //sort first k numbers
- Arrays.sort(a, 0, k);
- for (int x : a) {
- System.out.print(x+ " ");
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement