题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); scanner.useDelimiter("\n"); while (scanner.hasNext()) { String S = scanner.next(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < S.length();) { if (S.charAt(i)>='0' && S.charAt(i) <= '9') { builder.append("*"); while (i<S.length()) { if (S.charAt(i)>='0' && S.charAt(i) <= '9') { builder.append(S.charAt(i)); } else { break; } i++; } builder.append("*"); } else { builder.append(S.charAt(i)); i++; } } System.out.println(builder); } } }