Merge pull request #7 from weilinfox/master

bc up up up
This commit is contained in:
Si-Huan 2020-03-05 13:51:03 +08:00 committed by GitHub
commit 2ddf7dd938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -184,7 +184,10 @@ def bcMain(com):
com = com.replace("()", "") com = com.replace("()", "")
com = com.replace("x", "*") com = com.replace("x", "*")
com = com.replace("X", "*") com = com.replace("X", "*")
if (len(com) < 1):
return reportErr(1, "")
#省略乘号的支持 #省略乘号的支持
for i in range(1, len(com)-1, 1): for i in range(1, len(com)-1, 1):
if (com[i] == '(' and (com[i-1].isdigit() or com[i-1] == '.' or com[i-1] == '%' or com[i-1] == ')')): if (com[i] == '(' and (com[i-1].isdigit() or com[i-1] == '.' or com[i-1] == '%' or com[i-1] == ')')):
@ -194,7 +197,7 @@ def bcMain(com):
#部分情况开头加0 #部分情况开头加0
if (com[0] == '+' or com[0] == '-' or com[0] == '.'): if (com[0] == '+' or com[0] == '-' or com[0] == '.'):
com = '0' + com com = '0' + com
#print(com) #print(com)
#表达式合法性 #表达式合法性