一个数组{ "1", "2", "3", "4", "5", "6", "7", "8" }
生成8的5次方
效果:11111,11112,11113,11114,11115,11116,11117,11118
11121,11122,11123,11124,11125,11126,11127,11128
11131,11132,11133,11134,11135,11136,11137,11138,依此类推谢谢!
生成8的5次方
效果:11111,11112,11113,11114,11115,11116,11117,11118
11121,11122,11123,11124,11125,11126,11127,11128
11131,11132,11133,11134,11135,11136,11137,11138,依此类推谢谢!
{
string[] s = { "1", "2", "3", "4", "5", "6", "7", "8" };
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.Length; i++)
{
string s1 = s[i].ToString();
for (int j = 0; j < s.Length; j++)
{
if (j > 0) result.Append(",");
result.Append((s1 + s[j]).PadLeft(s.Length, s[0][0]));
}
result.AppendLine();
}
Console.WriteLine(result.ToString());
Console.ReadKey();
}
输出11111111,11111112,11111113,11111114,11111115,11111116,11111117,11111118
11111121,11111122,11111123,11111124,11111125,11111126,11111127,11111128
11111131,11111132,11111133,11111134,11111135,11111136,11111137,11111138
11111141,11111142,11111143,11111144,11111145,11111146,11111147,11111148
11111151,11111152,11111153,11111154,11111155,11111156,11111157,11111158
11111161,11111162,11111163,11111164,11111165,11111166,11111167,11111168
11111171,11111172,11111173,11111174,11111175,11111176,11111177,11111178
11111181,11111182,11111183,11111184,11111185,11111186,11111187,11111188
int[] src = { 1, 2, 3, 4, 5, 6,7,8};
foreach (int l0 in src)
{
foreach (int l1 in src)
{
foreach (int l2 in src)
{
foreach (int l3 in src)
{
foreach (int l4 in src)
{
Console.WriteLine(l0 * 10000 + l1 * 1000 + l2 * 100 + l3 * 10 + l4);
}
}
}
}
}