同步操作将从 编程语言算法集/Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# Print all subset combinations of n element in given set of r element.def combination_util(arr, n, r, index, data, i):"""Current combination is ready to be printed, print itarr[] ---> Input Arraydata[] ---> Temporary array to store current combinationstart & end ---> Staring and Ending indexes in arr[]index ---> Current index in data[]r ---> Size of a combination to be printed"""if index == r:for j in range(r):print(data[j], end=" ")print(" ")return# When no more elements are there to put in data[]if i >= n:return# current is included, put next at next locationdata[index] = arr[i]combination_util(arr, n, r, index + 1, data, i + 1)# current is excluded, replace it with# next (Note that i+1 is passed, but# index is not changed)combination_util(arr, n, r, index, data, i + 1)# The main function that prints all combinations# of size r in arr[] of size n. This function# mainly uses combinationUtil()def print_combination(arr, n, r):# A temporary array to store all combination one by onedata = [0] * r# Print all combination using temporary array 'data[]'combination_util(arr, n, r, 0, data, 0)# Driver function to check for above functionarr = [10, 20, 30, 40, 50]print_combination(arr, len(arr), 3)# This code is contributed by Ambuj sahu
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。