电脑版
首页

搜索 繁体

116、骂战(2/2)

055

077

079

063

094

at(obj);

}

061

Stringtemp=““;

078

}else{

068

}else{

053

string.substring(index temp.length());

086

Matchermatcher=null;

057

074

060

/**

*/

}catch(Exceptione){

085

096

index=string.indexOf(temp);

062

087

Stringregex=“\\([\\d\\.\\ \\-\\*/] \\)“;//提取括号表达式

while(pattern.matcher(string).find()){

returnstring;

publicstaticStringcomputeString(Stringstring){

075

076

}

}

//循环计算所有括号里的表达式

070

089

s=decimalFormat.format(obj);

//最后计算总的表达式结果

string=string.replaceAll(“\\s“,““);//去除空格

066

returne.getMessage();(未完待续。)

}

088

StringregexCheck=“[\\(\\)\\d\\ \\-\\*/\\.]*“;//是否是合法的表达式

059

093

081

try{

073

NumberFormatnumberFormat=NumberFormat.getInstance();

095

067

}

056

temp=matcher.group();

071

string=string.substring(0,index)

097

092

*计算字符串四则运算表达式

084

intindex=-1;

s=numberFormat.format(obj);

069

computeStirngNoBracket(temp)

Patternpattern=Patternpile(regex);

}catch(NumberFormatExceptione){

if(!Pattern.matches(regexCheck,string))

returns;

matcher=pattern.matcher(string);

072

string=computeStirngNoBracket(string);

DecimalFormatdecimalFormat=newDecimalFormat(format);

080

064

052

}

*@return

065

*@paramstring

054

058

083

082

091

while(matcher.find()){

090

热门小说推荐

最近更新小说