import sys def jud(x): m = 0 for i in x: if i == '-' or i == '+': return m m+=1 def jud2(s): m = 0 for i in s: if i == '=': return m m+=1 n = 0 a = 0 b = 0 c = 0 while True: try: line = input() if line[-1] == '?': continue else: a = int(line[0:jud(line)]) b = int(line[jud(line) + 1:jud2(line)]) c = int(line[jud2(line) + 1:]) if line[jud(line)] == '+' and c == a + b: n += 1 elif line[jud(line)] == '-' and c == a - b: n += 1 else: continue except: break print(n)
好的题解
#判断结果是否正确的函数 def check(s): if '?' in s: return False else: L = list(s) L.insert(L.index('='),'=') if eval("".join(L)): return True else: return False #正确题目数量 count = 0 while True: try : S = input() if check(S): count += 1 except: break print(count)
好的题解2
score = 0 while True: try: user = input().split("=") if user[1] == "?": continue if str(eval(user[0])) == user[1]: score += 1 except: break print(score)
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:702 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:827 |
C语言训练-数字母 (C语言代码)浏览:670 |
2005年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:637 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:606 |
简单的a+b (C语言代码)浏览:878 |
幸运数 (C++代码)浏览:1309 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:585 |
C语言训练-排序问题<1> (C语言代码)浏览:369 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:456 |