つまらないことに一つの金額を中国語のクラスに変換した.
2414 ワード
/**
*
*/
package test;
/**
* @author Cl
*
*/
public final class Money {
static String[] unit = {" "," "," "," "," "," "," "," "," "," "," "," "," "};
static String[] cn = {" "," "," "," "," "," "," "," "," "," "};
public static String changeToCN(String alb){
StringBuffer changed = new StringBuffer();
char[] achs = alb.toCharArray();
// for(char ach:achs){
// String sach = String.valueOf(ach);
// int d = Integer.parseInt(sach);
// changed.append(cn[d]);
// }
if(achs.length>13){
System.out.println(" , !");
return null;
}
else{
for(int i = 0;i<achs.length;i++){
String sach = String.valueOf(achs[i]);
int d = Integer.parseInt(sach);
String s = cn[d];
int e = achs.length-i-1;
if(s==" " && (e==0 || e==4 || e==8 || e==12)){
s=unit[e];
}
else if(s==" " && (e!=0 || e!=4 || e!=8 || e!=12)){
s=" ";
}
else{
s += unit[e];
}
changed.append(s);
}
String str = changed.toString();
if(str.contains(" ")){
str = str.replaceAll(" ", " ");
}
if(str.contains(" ")){
str = str.replaceAll(" ", " ");
}
while(str.contains(" ") || str.contains(" ") || str.contains(" ")){
str = str.replaceAll(" ", " ");
str = str.replaceAll(" ", " ");
str = str.replaceAll(" ", " ");
str = str.replaceAll(" ", " ");
str = str.replaceAll(" ", " ");
}
return str;
}
}
/**
* @param args
*/
public static void main(String[] args) {
String s = Money.changeToCN("100000001");
System.out.println(s);
}
}
発表後、ネットでこの問題の解決方法を調べた.ある仁兄のアルゴリズムと構想が自分とそっくりだと見た.ははは!天涯にはどこにも知己がいない!