2023-11-12
思路:Java很简单,先将字符串分割,再重新拼接,如果是在本串操作(Java不行哦)
那么可以先将整体反转,在将2个子串分别反转
import java.util.Scanner; public class Main { public static void main(String[] args) { int k; String s; Scanner sc=new Scanner(System.in); k=sc.nextInt(); s=sc.next(); String newS=xxx(k,s); System.out.println(newS); } public static String xxx(int k,String s){ String newS; String s1=s.substring(0,s.length()-k); String s2=s.substring(s.length()-k,s.length()); newS=s2+s1; return newS; } }
标签:String,55,右旋,第八期,length,sc,newS,public,Scanner From: https://www.cnblogs.com/youye9527/p/17827950.html