题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextLine()) { String input = in.nextLine(); int flag = 0; for (int i = 0; i < input.length(); i++) { if (flag == 0 && input.charAt(i) >= '0' && input.charAt(i) <= '9') { System.out.print("*"); flag = 1; } if (flag == 1 && (input.charAt(i) < '0' || input.charAt(i) > '9')) { System.out.print("*"); flag = 0; } System.out.print(input.charAt(i)); if (i==input.length()-1&&flag==1){ System.out.print("*"); } } } } }