世界杯736什么意思?
736是数字游戏“24”的一个变种,把0-9这十个数字任意排出,两两相减得到余数,然后按照由小到大的顺序,把所有的余数相加,得到的和就是736。这个游戏可以验证一个人的计算是否正确,通常被用来检验小孩的数学学习情况。 下面是程序代码(使用python语言编写):
def calc(arr): # function for calculation of 736
r=0 # initialize sum varible
for i in range(10): # iterate over the 10 numbers from 0 to 9
j=i+1 # increment j by 1 until it gets to 10
temp=int(arr+arr[j]) # calculate temp which is the sum of two consecutive nums
if (temp%2==0): r+=temp/2 # check if number is even, if yes then add half of that number to total sum
else: r+=temp # else add whole number to the total
return r # return the sum
测试一下:
print(calc([4,3,1,5])) # testing
85 答案是 85 对吗?!~