-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (30 loc) · 1.03 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from ariExpression import Ari_Expression
from infixTosuffix import infix_to_suffix
import Calculate
import profile
def main():
max_num=10
problem = int(input('请输入需要的题目数量:'))
i = 1
correct =0
wrong =0
print("本次测试共{}题,满分100分".format(problem))
while i < problem + 1:
ari = Ari_Expression(max_num)
inf = infix_to_suffix()
real_res = Calculate.getResult(inf.str_to_fraction(inf.to_suffix_expression(ari.str)))
if real_res >= 0:
print("------------------------------")
real_res = ari.str_num(real_res)
print(str(i)+'. ' + ari.str, end = '')
res = input()
if res == real_res:
correct += 1
print("回答正确!")
else:
wrong += 1
print("回答错误!正确答案为:{}".format(real_res))
i += 1
print('\n得分为:' + str(correct/problem*100))
if __name__ == '__main__':
profile.run("main()")