python 实现
注:输入的数据需要在区间 [1,1000] 内
s=input() loc=s.index(" ") a=s[:loc] b=s[loc+1:] if a.isdecimal() and b.isdecimal(): if int(a) in [i for i in range(1,1001)] and int(b) in [i for i in range(1,1001)]: print("{a} + {b} = {sum}".format(a=a, b=b, sum=int(a) + int(b))) elif int(a) in [i for i in range(1,1001)]: print("{a} + ? = ?".format(a=a)) elif int(b) in [i for i in range(1,1001)]: print("? + {b} = ?".format(b=b)) else: print("? + ? = ?") elif a.isdecimal(): if int(a) in [i for i in range(1,1001)]: print("{a} + ? = ?".format(a=a)) else: print("? + ? = ?") elif b.isdecimal(): if int(b) in [i for i in range(1,1001)]: print("? + {b} = ?".format(b=b)) else: print("? + ? = ?") else: print("? + ? = ?")
标签:elif,format,python,025,int,range,L1,print,1001 From: https://www.cnblogs.com/forkroad/p/18276936