Home > Net >  How to implement a character array of fixed length of character combinations
How to implement a character array of fixed length of character combinations

Time:11-08

For example, I have a character array totalTest={" 0 ", "1", "2", "3"... "?" , "/"... A total of 94, also can choose some, up to 94}
And then do a function ProA (password length)
Finally can click password length setting, enumerated all character combinations, such as: password length is 5, after are enumerated as follows:
00000
00001
00002
00003
00004
00005
00006
00007
00008
00009
0000 a
0000 b
.
00010
.
0001?
.
Please feel free to comment. Thanks

CodePudding user response:

Suggest using an array of strings to complete

If the password length less than a specified length in front to add 0
The intL=strA. Length
If intL<5 then
For intI=1 to 5 - intL
StrA="0" & amp; StrA
Next
end if

CodePudding user response:

Suddenly and violently broken, if the initial change [0-9] you can write, I believe that you would, that is not to count
?
[0-9] ok, can you write, that is decimal, change the condition, {" 0 ", "1", "2", "3"... "?" , "/"... A total of 94 94 into the system, it is not the full 94 into a

94 into the system, of course, 94 into the system to be a large number five, int, long may not be able to express,

We can switch to functional writing, this I don't want to write much now, just thinking, f (f1, f2, f3, f4 (f5)))))

CodePudding user response:

I don't want to waste brains make perfect writing, is a simple demo, but I also don't want to get pure functional, direct object type was used to simulate the

 testxx f1=new testxx (0); 
Testxx f2=new testxx (0);
Testxx f3=new testxx (0);
Testxx f4=new testxx (0);
Testxx f5=new testxx (0);

F5. Parent=f4;
F4. Parent=f3;
F3. Parent=f2;
F2. The parent=f1;

//this string of initial process, can use the code, just a simple demo, I'm too lazy to write so complete
For (int I=0; i <100; I++)
{
Var res=f5.com puteEx ();
Console. WriteLine (string. Join (", ", res));
}



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Object

 public class testxx 
{
Public testxx parent {get; set; }

Public int value
{
The get;
set;
}

Public testxx (int init)
{
Value=https://bbs.csdn.net/topics/init;


}

Public void compute ()
{
Value++;
If (value=94 https://bbs.csdn.net/topics/=
{
The value -=94;
The parent? Compute ();
}
}

}


Extension methods

 public static IEnumerable ComputeEx (this testxx LST) 
{
Var obj=LST;


Var res=LST. ParentValue ();
The foreach (var re in res)
{
Yield return re;
}


Obj.com pute ();
}

Private static IEnumerable ParentValue (this testxx obj)
{
If (obj. Parent!=null)
{
Var b=obj. Parent. ParentValue ();
The foreach (var I in b)
{
Yield return I;
}
}
Yield return obj. Value;
}
  • Related