package b; import java.util.Scanner; public class Zifuchuan { public static void main(String[] args) { System.out.println("输入字符串:"); Scanner zifu=new Scanner(System.in); String s=zifu.nextLine(); String shuzi="123456789"; for (int i = 0; i < s.length(); i++) { if(shuzi.replace(s.substring(i, i+1), "").length()==(shuzi.length()-1) &&i<s.length()-1) { int n=new Integer(s.substring(i, i+1)); for (int j = 0; j <n+1; j++) { System.out.print(s.substring(i+1,i+2)); } System.out.print("_"); } else if(shuzi.replace(s.substring(i, i+1), "").length()==(shuzi.length()-1) &&i==s.length()-1) { System.out.print(s.substring(i,i+1)); } else if(s.substring(i, i+1).equals("_")&&i<s.length()-1) { System.out.print("\\UL"); System.out.print("_"); } else if(s.substring(i, i+1).equals("_")&&i==s.length()-1) { System.out.print("\\UL"); } else if(i<s.length()-1) { System.out.print(s.substring(i, i+1)); System.out.print("_"); } else { System.out.print(s.substring(i, i+1)); } } } }
转载于:https://www.cnblogs.com/wenwen123/p/5520338.html