Home > Net >  Group 12.3456789 billion figures into two halves (five), list all combinations not repeat use progra
Group 12.3456789 billion figures into two halves (five), list all combinations not repeat use progra

Time:11-07

Group 12.3456789 billion figures into two halves (five), not to repeat, list all combination with program realization program code
Such as:
12345, 67890
13456278, 90,
14567238, 90,
.

CodePudding user response:

The whole group after arrangement

CodePudding user response:

You this topic is 10 number of column combinations, to character, former after five, refer to the following url, modification can use the
https://www.cnblogs.com/gpcuster/archive/2007/11/17/962848.html

CodePudding user response:

The static List Permutation (string strArr)
{
List List=new List (a);
String Permutation="";
Int length=strArr length, startLength=length - (length & gt; 2? 2:1) *//* set to skip digits, end=startLength;
Int [] intArr=Enumerable. Repeat (0, startLength). ToArray ();
Do/* 16 ~ 17 o 'clock on January 29, 2016:1. The string does not transfer array (2) string to exchange position not only according to the change of the subscript readOnly3. Reduce half cycle length directly by 2 permutation and combination of high efficiency 4. According to the order of the output does not need to reorder 5. Automatic outin code length less than 6. Write a fixed outin can still be an array, reduce a outin can save a lot of cycle length, with direct access to the most down2 combination can save half of the cycle length, this is only half cycle to generate the length, but not with the number of inversion logic, wonderful! Is the algorithm of quick tips, but this way is save half cycle length feel incredible feeling, */
{
If (length & lt; 2) break;
While (- end & gt;=0)/* outin operation step by step */
If (intArr [end] & gt;=length - end)
{
If (end - 1 & lt; 0) break;/* to prevent cross-border */
+ + intArr [end - 1);
IntArr [end]=0;
}
If (intArr [0] {
End=0;/* the Console. WriteLine (string. Join (" ", infinite outin)); */
The foreach (int outin the in intArr)
Permutation=StrLength (end==0? StrArr: Permutation, length, end, outin + end++);
List. The Add (Permutation);
List. Add ((length & gt; 2? StrLength (Permutation, length, length - 2, length - 1) : ""));
}
+ + intArr [startLength - 1);
End=startLength;
Permutation="";
} while (intArr [0] return list;
}
The static string StrLength (string strArr, int length, int insert, int sit)
{
If (insert==sit) return strArr;
Insert=Math. Abs (insert %=length); Sit=Math. Abs (sit %=length);
String up=", "down=" ", read="";
Int head=0, foot=length - 1;
Action Plus=delegate (bool state)
{
If (state) {up +=read; + + head; } else {down=read + down; - foot; }
};
Action ReadOnly=delegate (bool state)
{
Read=(state? Head: foot)!=sit? StrArr [(state? Head: foot)]. The ToString () : "";
Plus (state);
};
Action Operation=delegate (bool state)
{
If ((state? Head: foot) & lt; The insert) readOnly (state);
Else if ((state? Head: foot)==insert)
{
Read=strArr [r]. Sit ToString () + (insert!=sit? StrArr [r]. Insert the ToString () : "");
Plus (state);
}
Else if ((state? Head: foot) & gt; The insert) readOnly (state);
};
Do
{/* character length parity operation, USES the binary I said two-way operation, reduce the cycle length to improve the operation speed, is effective for reducing overall time 17:59 */2016-1-30
If (head & lt;=foot) operation (true);
If (head & lt; Foot) operation (false);
} while (head & lt;=foot);
Return up + down;
}

Private void button1_Click (object sender, EventArgs e)
{
List List=Permutation (" 0123456789 ");
List Temp=new List (a);
The foreach (var item in the list)
{
TextBox1. AppendText (item + "\ t");
}
}

CodePudding user response:

Factorial algorithm verification number

CodePudding user response:

This is m n algorithm, m=10, n=5, 5 are selected, the remaining five also identified the
https://bbs.csdn.net/topics/390550326
  •  Tags:  
  • C#
  • Related