La copia del código es la siguiente:
import java.util.hashmap;
import java.util.map;
clase pública FigureAndChinese2util {
// caché todos los números
mapa estático privado <carácter, carácter> map = nuevo hashmap <caracteres, caracteres> (
10);
estático {
map.put ('1', '1');
map.put ('2', '2');
map.put ('3', 'tres');
map.put ('4', 'si');
map.put ('5', 'wu');
map.put ('6', 'lu');
map.put ('7', 'qi');
map.put ('8', '8');
map.put ('9', '9');
map.put ('0', 'cero');
}
static char [] mode = new Char [] {'ella', 'bai', 'qian'};
public static void m (String sb) {
StringBuffer sbf = new StringBuffer ();
Cadena [] sp = sb.split ("//.");
if (sp.length == 2) {
m0 (sp [0], 0, sbf);
sbf.append (m2 (sp [1]));
} demás
M0 (SB, 0, SBF);
sbf.append ("entero");
System.out.println (SBF);
}
/***
* Corte de cadena
*
* @param sb
*/
public static void m0 (string sb, int type, stringbuffer sbf) {
int len = sb.length ();
int b = 0;
tipo ++;
if (len> = 4) {
b = len - 4;
sbf.insert (0, m1 (sb.substring (b), tipo));
m0 (sb.substring (0, b), tipo, sbf);
} else if (len> 0)
sbf.insert (0, m1 (sb, type));
if ('cero' == sbf.charat (0))
sbf.deletecharat (0);
}
/***
* tratar con
*
* @param sb
*/
public static stringbuffer m1 (string sb, int type) {
StringBuffer sbf = new StringBuffer (SB);
Switch (tipo) {
Caso 1:
sbf.append ("círculo");
romper;
Caso 2:
sbf.append ("diez mil");
romper;
Caso 3:
sbf.append ("中");
romper;
por defecto:
romper;
}
// Iniciar asignación
int b = 0;
char t = 0;
para (int i = sbf.length ()-2; i> = 0; i--) {
t = sbf.charat (i);
sbf.setcharat (i, map.get (t));
if (i! = 0)
sbf.insert (i, modo [b]);
b ++;
}
para (int i = 0; i <sbf.length (); i ++) {
t = sbf.charat (i);
if (t == 'cero') {
t = sbf.charat (i + 1);
if ('circle'! = t && 'millones'! = t && 'millones'! = t)
sbf.deletecharat (i + 1);
demás
sbf.deletecharat (i);
if (i! = 0)
if (sbf.charat (i - 1) == 'cero') {
sbf.deletecharat (i - 1);
i--;
}
}
}
if (sbf.length () == 1) {
if ('circle'! = sbf.charat (0))
sbf.setLength (0);
}
devolver sbf;
}
public static stringbuffer m2 (string de) {
if (de.length ()> 2)
de = de.substring (0, 2);
de = de.replaceFirst ("00", "");
StringBuffer sb = new StringBuffer (DE);
if (sb.length ()> 0) {
if (sb.charat (sb.length () - 1) == '0')
sb.deletecharat (sb.length () - 1);
sb.setcharat (0, map.get (sb.charat (0)));
switch (sb.length ()) {
Caso 1:
sb.append ("ángulo");
romper;
Caso 2:
sb.setcharat (1, map.get (sb.charat (1)));
if (sb.charat (0)! = 'cero')
sb.insert (1, 'ángulo');
sb.append ("puntaje");
romper;
por defecto:
romper;
}
}
regresar SB;
}
public static void main (string [] args) {
Cadena s = "44444444441.23";
Cadena s1 = "1";
Cadena S2 = "1000000000.01";
Cadena S3 = "101010002.11";
EM);
m (S1);
m (S2);
m (S3);
}
}