电脑版
首页

搜索 繁体

116、骂战(2/2)

057

076

070

052

083

062

084

at(obj);

returns;

087

059

try{

}

095

085

075

090

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

s=decimalFormat.format(obj);

055

}

}

072

Stringtemp=““;

}

086

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

publicstaticStringcomputeString(Stringstring){

temp=matcher.group();

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

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

081

}

078

054

088

string=computeStirngNoBracket(string);

NumberFormatnumberFormat=NumberFormat.getInstance();

080

}else{

063

066

091

053

}catch(NumberFormatExceptione){

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

056

*/

s=numberFormat.format(obj);

077

}

092

index=string.indexOf(temp);

071

*@paramstring

060

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

computeStirngNoBracket(temp)

064

073

returnstring;

Matchermatcher=null;

089

Patternpattern=Patternpile(regex);

}catch(Exceptione){

094

079

058

074

DecimalFormatdecimalFormat=newDecimalFormat(format);

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

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

matcher=pattern.matcher(string);

068

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

069

082

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

while(matcher.find()){

/**

intindex=-1;

096

}else{

061

067

*@return

097

093

string=string.substring(0,index)

065

热门小说推荐

最近更新小说