Ämne: Permutation
Visa ett inlägg
Oläst 2009-03-13, 04:45 #5
eg0master eg0master är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Oct 2004
Inlägg: 898
eg0master eg0master är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Oct 2004
Inlägg: 898
Och nu lite pseudokod för att lösa problemet:
Kod:
print_array_permutation(array):
  print_array_permutation_helper(array, empty_array)

print_array_permutation_helper(array_in, array_out)
  if array_in.length == 0
    print array_out
  else
    for index = 0 to array_in.length - 1
      object = array_in[index]
      in = array_in.copy()
      in.removeAt(index)
      out = array_out.copy()
      out.append(object)
      print_array_permutation_helper(in, out)
eg0master är inte uppkopplad   Svara med citatSvara med citat