38 lines
805 B
Java
38 lines
805 B
Java
package com.thinker.bishi.other;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class StringRotation{
|
|
|
|
public static void main(String[] args){
|
|
Scanner in = new Scanner(System.in);
|
|
String str = in.nextLine();
|
|
String[] strs = str.split(",");
|
|
str = strs[0].substring(1,strs[0].length()-1);
|
|
int len = Integer.parseInt(strs[1]);
|
|
int loca = Integer.parseInt(strs[2]);
|
|
StringRotation s = new StringRotation();
|
|
System.out.println(s.rotateString(str,len,loca));
|
|
|
|
}
|
|
|
|
public String rotateString(String A, int n, int p){
|
|
char[] a = A.toCharArray();
|
|
rotate(a,0,p);
|
|
rotate(a,p+1,n-1);
|
|
rotate(a,0,n-1);
|
|
return new String(a);
|
|
}
|
|
|
|
public void rotate(char[] a, int begin, int end){
|
|
while(begin <= end){
|
|
char tmp = a[begin];
|
|
a[begin] = a[end];
|
|
a[end] = tmp;
|
|
begin ++;
|
|
end --;
|
|
|
|
}
|
|
}
|
|
}
|