algorithm - All Possible combinations in C -
i'm trying find efficient algorithm in c, provides me combinations of given charset.
the algorithm should not recursive. @ last number of digits should flexible. example:
char set[] = "a1"; -> a1 aa 1a 11 i've found perl solution, uses substr(). think wasn't fast performance-wise.
for algorithms in c, i've found permutations...
a article in german c++ forum claims, c++-stl solutions faster "raw" recursive algorithms.
if set size fixed n simple - have n for loops, each 1 nested previous one. since can't , can't use recursion, have calculate total required number of iterations (seems it's n^m), use 1 single loop , use / , % calculate array index of each character should be. you'd better use longs well, because n^m gets big fast.
Comments
Post a Comment