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://images2015.cnblogs.com/blog/917851/201605/917851-20160523160209194-345282516.png)
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160523160221819-1947547862.png)
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160523160234663-877371661.png)