繁体版 简体版
非凡小说网 > 都市言情 > 我的1979 > 15、骂战

15、骂战(第2页/共2页)

052

}else{

053

DecimalFormatdecimalFormat=newDecimalFormat(format);

054

s=(obj);

055

}

056

}else{

057

NumberFormatnumberFormat=;

058

s=(obj);

059

}

060

}catch(Exceptione){

061

}

062

returns;

063

}

064

065

/**

066

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

067

*amstring

068

*urn

069

*/

070

publicstaticStringputeString(Stringstring){

071

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

072

073

if(!(regexCheck,string))

074

returnstring;

075

076

Matchermatcher=null;

077

Stringtemp=““;

078

intindex=-1;

079

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

080

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

081

try{

082

Patternpattern=(regex);

083

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

084

while((string).find){

085

matcher=(string);

086

while{

087

temp=;

088

index=(temp);

089

string=(0,index)

090

+puteStirngNoBracket(temp)

091

+(index+);

092

}

093

}

094

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

095

string=puteStirngNoBracket(string);

096

}catch(NumberFormatExceptione){

097

(未完待续。)

您阅读的小说来自:非凡小说网,网址:www.xiaoshuoff.com

『加入书签,方便阅读』(第2页/共2页)