代码如下:
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int num = input.nextInt(); int k = input.nextInt(); int[] arr = new int[num]; for(int i=0;i<num;i++){ arr[i] = input.nextInt(); } if(k%num==0){ for(int i = 0;i<num;i++){ if(i==(num-1)){ System.out.print(arr[i]); }else{ System.out.print(arr[i]+" "); } } }else{ for(int i = num-k%num;i<num;i++){ System.out.print(arr[i]+" "); } for(int i = 0;i<num-k%num;i++){ if(i==(num-k%num-1)){ System.out.println(arr[i]); }else{ System.out.print(arr[i]+" "); } } } } }