题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); String zfc = fzhinput.nextLine(); StringBuilder stack = new StringBuilder(); boolean pd=true; for(int i=0;i<zfc.length();i++){ if(Character.isDigit(zfc.charAt(i))&&pd){ stack.append('*'); pd=false; } else if(pd==false&&!Character.isDigit(zfc.charAt(i))){ stack.append('*'); pd=true; } else if(!Character.isDigit(zfc.charAt(i))){ pd=true; } stack.append(zfc.charAt(i)); } if(pd==false){ stack.append('*'); } System.out.println(stack.toString()); } }