online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
def subsets( nums ) : all_subset = [] bag = [] # ---------------------------------------- # i : 索引值, 從 0 ~ n-1 def picker( i ): ## 終止條件 # 當所有號碼都已經考慮過了 if i == len(nums): all_subset.append( bag[::] ) return ## 遞迴關係式: # 對當下這個號碼,有兩種可能情況,拿這個號碼,或者不拿這個號碼。 # 可能情況a: 拿當下這個號碼 bag.append( nums[i] ) picker( i+1 ) bag.pop() # 可能情況b: 不拿當下這個號碼 picker( i+1 ) return # ----------------------------------------- # 從第一個號碼開始 picker( 0 ) return all_subset # 範例:假定輸入是[1, 2, 3] numbers = [1,2,3] result = subsets( numbers ) # 範例輸出: [[1, 2, 3], [1, 2], [1, 3], [1], [2, 3], [2], [3], []] print( result )

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue