It may take a day before you come out to work, and you will find that you don't have to learn well in college. Now you have to pick up a lot of things. According to a complete. net self-learning plan, it is now a learning stage of algorithms. I want to share some experiences ~ This time I want to talk about the full arrangement. "For example, a, B, and c are arranged in the following ways: abc, acb, bac, bca, cab, and CBA. N elements are arranged in a total of n! ." The book uses a recursive method. It is a bit strange because it uses the C ++ language ~ A non-recursive method is coming up with a radical expression. It is written in C #. I hope it can be used as a reference. Thank you.
Class Perm
...{
Private List <string> permPreList;
Private List <string> permedList;
Public Perm (List <string> list)
...{
PermPreList = list;
PermedList = new List <string> ();
}
Public List <string> PermedList
...{
Get
...{
Return permedList;
}
}
Public void GetPerm ()
...{
For (int I = 0; I <permPreList. Count; I ++)
...{
String first = permPreList [I];
For (int j = 0; j <permPreList. Count; j ++)
...{
If (j! = I)
...{
String second = permPreList [j];
For (int k = 0; k <permPreList. Count; k ++)
...{
If (k! = J & k! = I)
...{
String third = permPreList [k];
PermedList. Add (first + second + third );
}
}
}
}
}
}
}
Throw more bricks ~.~
<