本题目要求对一个20位长的数组进行操作,当输入一个0-19的整数时,把该位上的数据删除,然后依次把后面的数组中的数据依次前移,把最后一位填0。
输入格式:
输入一个整数(0-19)。
输出格式:
使用Arrays.toString输出。
输入样例:
在这里给出一组输入。例如:
13
输出样例:
在这里给出相应的输出。例如:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 0]
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int num = input.nextInt();
int[] ans = new int[20];
for(int i = 0; i < num; i++) {
ans[i] = i;
}
for(int i = num; i < 19; i++) {
ans[i] = i + 1;
}
System.out.println(Arrays.toString(ans));
}
}