2023.8.8 周二:replace All
1 /* 2 输入格式: 3 输入在一行中给出一句话,即一个非空字符串,由不超过 1000 个英文字母、数字和空格组成,以回车结束。 4 5 输出格式: 6 从左到右扫描输入的句子:如果句子中有超过 3 个连续的 6,则将这串连续的 6 替换成 9;但如果有超过 9 个连续的 6,则将这串连续的 6 替换成 27。其他内容不受影响,原样输出。 7 */ 8 9 //it is so 666 really 6666 what else can I say 6666666666 10 11 import java.util.Scanner; 12 import java.lang.String; 13 public class Main { 14 public static void main(String[] args) { 15 Scanner input = new Scanner(System.in); 16 String s = input.nextLine(); 17 s = s.replaceAll("6{10}","27"); 18 s = s.replaceAll("6{4}","9"); 19 System.out.println(s); 20 21 } 22 } 23 //it is so 666 really 9 what else can I say 27