using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace ConsoleApplication1 { class Program { static void Main(string[] args) { for (int i = 1; i < 100; i++) Console.WriteLine(RandNum()); } static string RandNum() { var rnd1 = "abc".OrderBy(x => Guid.NewGuid()).ToArray(); var r = new Random(Guid.NewGuid().GetHashCode()); int rnd2 = r.Next(0, 4); int rnd3 = r.Next(0, 10); return new string(rnd1.Take(rnd2).ToArray()) + rnd3.ToString() + new string(rnd1.Skip(rnd2).ToArray()); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i=1; while (i <= 100) { Random r = new Random(); int rand = r.Next(10); string s = "abc" + rand.ToString(); char[] ch = s.ToCharArray(); string result = ""; while (result.Length < 4) { Random randtemp = new Random(); int rtemp = randtemp.Next(ch.Length); if (result.IndexOf(ch[rtemp].ToString()) == -1) { result += ch[rtemp].ToString(); } } Console.WriteLine(result); i++; }
Console.ReadKey(); } } }
string str = "abc"; Random rand = new Random(); str = str.Insert(rand.Next(4), rand.Next(10).ToString()); Console.WriteLine(str);
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i < 100; i++)
Console.WriteLine(RandNum());
} static string RandNum()
{
var rnd1 = "abc".OrderBy(x => Guid.NewGuid()).ToArray();
var r = new Random(Guid.NewGuid().GetHashCode());
int rnd2 = r.Next(0, 4);
int rnd3 = r.Next(0, 10);
return new string(rnd1.Take(rnd2).ToArray()) + rnd3.ToString() + new string(rnd1.Skip(rnd2).ToArray());
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i=1;
while (i <= 100)
{
Random r = new Random();
int rand = r.Next(10);
string s = "abc" + rand.ToString();
char[] ch = s.ToCharArray();
string result = "";
while (result.Length < 4)
{
Random randtemp = new Random();
int rtemp = randtemp.Next(ch.Length);
if (result.IndexOf(ch[rtemp].ToString()) == -1)
{
result += ch[rtemp].ToString();
}
}
Console.WriteLine(result);
i++;
}
Console.ReadKey();
}
}
}
string str = "abc";
Random rand = new Random();
str = str.Insert(rand.Next(4), rand.Next(10).ToString());
Console.WriteLine(str);
晕,需要abc 任意排列的情况下,在增加 0到9任意一位数字..产生一个4位数字的字典.
晕,需要abc 任意排列的情况下,在增加 0到9任意一位数字..产生一个4位数字的字典.
abc 不需要固定位置..
0到9,任意一位数字插入到abc中...
题目我写的很清楚啊.
0acb
1acb
2acb
3acb
4acb
5acb
a9cb
7acb
8acb
9acb
a9cb
a1cb
a9cb
a3cb
a4cb
a5cb
a6cb
a7cb
a8cb
a9cb
a9cb
a9cb
a9cb
a9cb
a9cb
a9cb
a9cb例如这样.
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
foreach (string s in All())
{
Console.WriteLine(s);
}
} static IEnumerable<string> All()
{
return Enumerable.Range(0, 40).SelectMany(x => new string[] { "abc", "acb", "bac", "bca", "cab", "cba" }.Select(y => y.Insert(x / 10, (x % 10).ToString())));
}
}
}