在使用if-if 时执行语句中不能改变判断表达式中的变量,否则会影响判断,如下列:
if(str1 == "") str1 = "reciproc(" + str2 + ")";
if(str1 != "") str1 = str1 + " reciproc(" + str2 + ")";
应该为:
if(str1 == "") str = "reciproc(" + str2 + ")";
if(str1 != "") str= str1 + " reciproc(" + str2 + ")";
str1 = str;
或采用if-else的形式:
if(str == "")
str1 = "reciproc(" + str2 + ")";
else
str1 = str1 + " reciproc(" + str2 + ")";