假设我有字符串:“ aab + bab = b ”,我想
a
用整数 0 替换所有字符,b
用整数 1替换所有字符
所以它会变成:
001 + 101 = 1
最简单的方法是什么?
到目前为止,我将方程式分为三个部分:
System.out.println("Enter an Equation of variables");
_inString = _in.nextLine();
//find the three different parts of the equation
String _noSpaces = _inString.replaceAll("\\s+","");
String delims = "[+,=]";
String[] _tokens = _noSpaces.split(delims);