2023-11-16
思路:
如果是c++,字符串可以改变,考虑双指针
但是Java的字符串不可变,所以就是按照题目的意思完成就行
import java.util.Scanner; class Main{ public static void main(String[] args) { // String s="a1b2c3"; Scanner sc=new Scanner(System.in); String s=sc.next(); // String s="a1b2c3d4f5g6"; s=xxx(s); System.out.println(s); } public static String xxx(String s){ int n=s.length(); for(int i=0;i<n;i++){ char c=s.charAt(i); if(c>='0' && c<='9'){ String s1=s.substring(0,i); String s2=s.substring(i+1,s.length());//a number b2c3 s=s1+"number"+s2; i+=5; n+=5; } } return s; } }
标签:卡码,String,int,54,System,第八期,static,public,Scanner From: https://www.cnblogs.com/youye9527/p/17836984.html