110,534
社区成员
发帖
与我相关
我的任务
分享
using System;
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())));
}
}
}
string str = "abc";
Random rand = new Random();
str = str.Insert(rand.Next(4), rand.Next(10).ToString());
Console.WriteLine(str);
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();
}
}
}
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());
}
}
}