我在网上找了很多关于组合的代码?
看起来就晕,或者没有找到符合我的意思的学习资料
我需要例如:从01 02 到11这11个数中任意选取5个、4个、3个或者2个数的组合,不需要大小顺序、位顺序,请大家帮忙写一个学习代码,并请详细注明注释(小虾是一个刚刚学习c#的新手)
看起来就晕,或者没有找到符合我的意思的学习资料
我需要例如:从01 02 到11这11个数中任意选取5个、4个、3个或者2个数的组合,不需要大小顺序、位顺序,请大家帮忙写一个学习代码,并请详细注明注释(小虾是一个刚刚学习c#的新手)
解决方案 »
- Asp.net写采集正则问题
- Excel-Dataset 为什么一直报错
- 问一个小问题.关于linkbutton文字居中.
- 在C# 中制作号看的 按钮或事件图标 怎么做啊
- 初学者求救!建立了控制台,建立了几个在不同命名空间的类,如何在Main()中调用其他类中的方法。
- 如何将img图片写到oracle数据库中
- 谁知道flygoldfish (长江支流) MIS金质打印程序有一个严重的问题.
- win8,8.1的任务管理器里的任务列表用的什么控件?或者说用的哪几个控件?怎么做到的?
- 如何在Windows程序显示多个面板???
- 怎么无法引入System.Net.Sockets
- 分享:堆和栈的区别
- 大家帮忙进来看下这段代码
Random Rnd = new Random();
string rel = "";
List<int> num = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
for (int i = 0; i < Rnd.Next(1, num.Count); i++)
{
Random Rnd1 = new Random();
int j = Rnd1.Next(0, num.Count);
rel += num[j].ToString() + ",";
num.RemoveAt(j);
}
Console.WriteLine("{0}",rel);
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
string[] str={"01","02","03","04","05","06","07","08","09","10","11"};
string a1, a2, a3, a4, a5;
for (int i = 0; i < str.Length - 1; i++)
{
a1 = str[i];
for (int j = i + 1; j < str.Length; j++)
{
a2 = str[j];
listBox2.Items.Add(a1+" "+a2);
for (int n = j + 1; n < str.Length; n++)
{
a3 = str[n];
listBox3.Items.Add(a1+" "+a2+" "+a3);
for (int m = n + 1; m < str.Length; m++)
{
a4 = str[m];
listBox4.Items.Add(a1+" "+a2+" "+a3+" "+a4);
for (int k = m + 1; k < str.Length; k++)
{
a5 = str[k];
listBox1.Items.Add(a1 + " " + a2 + " " + a3 + " " + a4 + " " + a5);
}
}
}
}
} label3.Text = listBox1.Items.Count.ToString();
label4.Text = listBox2.Items.Count.ToString();
label5.Text = listBox3.Items.Count.ToString();
label6.Text = listBox4.Items.Count.ToString();
}
}
}