题解 | #人民币转换#
表示数字
http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
while(in.hasNextLine()){
String str = in.nextLine();
String res = "";
int k = 0;
int m = 0;
boolean isNum = false;
while(k < str.length()){
if(str.charAt(k)>='0'&&str.charAt(k)<='9'){
if(!isNum){
res += str.substring(m, k);
m = k;
isNum = true;
} else {
if(++k == str.length()){
res += "*" + str.substring(m, k) + "*";
}
}
} else {
if(isNum){
res += "*" + str.substring(m, k) + "*";
m = k;
isNum = false;
} else {
if(++k == str.length()){
res += str.substring(m, k);
}
}
}
}
System.out.println(res);
}
}
}
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
while(in.hasNextLine()){
String str = in.nextLine();
String res = "";
int k = 0;
int m = 0;
boolean isNum = false;
while(k < str.length()){
if(str.charAt(k)>='0'&&str.charAt(k)<='9'){
if(!isNum){
res += str.substring(m, k);
m = k;
isNum = true;
} else {
if(++k == str.length()){
res += "*" + str.substring(m, k) + "*";
}
}
} else {
if(isNum){
res += "*" + str.substring(m, k) + "*";
m = k;
isNum = false;
} else {
if(++k == str.length()){
res += str.substring(m, k);
}
}
}
}
System.out.println(res);
}
}
}