代码展示:
import java.util.Scanner;
public class Abc {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
String t=input.nextLine(); //以字符串的形式接收
String[] t1=t.split(",");
String t3=input.nextLine();
String[] t2=t3.split(",");
int n=Integer.parseInt(t1[0]);
int k=Integer.parseInt(t1[1]);
int[] a=new int[n];
for(int i=0;i<n;i++)
{
a[i]=Integer.parseInt(t2[i]);
}
LeftShift(a,n,k);
input.close();
}
private static void LeftShift(int[] a, int n, int k) {
// TODO Auto-generated method stub
int[] s=new int[n];
for(int i=0;i<n;i++)
{
s[i]=a[k];
k++;
if(k==6)
{
k=0;
}
}
for(int i=0;i<n;i++)
{
a[i]=s[i];
}
System.out.print(a[0]);
for(int i=1;i<n;i++)
{
System.out.print(","+a[i]);
}
}
}