© 1999-2048 dssz.net 粤ICP备11031372号
[其它] Python算法输出1-9数组形成的结果为100的所有运算式
说明:问题: 编写一个在1,2,…,9(顺序不能变)数字之间插入+或-或什么都不插入,使得计算结果总是100的程序,并输出所有的可能性。例如:1 + 2 + 34–5 + 67–8 + 9 = 100。 from functools import reduce operator = { 1: '+', 2: '-', 0: '' } base = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] def isHundred(num): #转化为8位3<weixin_38733525> 上传 | 大小:45kb