asp.net 数组匹配问题 150
asp.net数组匹配问题我现在有10个数组匹配在十个数组里面有很多数字例如a{1,2,3,4,5}b{3,2,1,a,b}c{d,f,r,e,x,c}d{b,t,y,h...
asp.net 数组匹配问题 我现在有10个数组 匹配 在十个数组里面有 很多数字 例如
a{1,2,3,4,5}
b{3,2,1,a,b}
c{d,f,r,e,x,c}
d{b,t,y,h,g}
e{b,d,r}
f{0,23,15,06,05}
......
一共十组 我怎么匹配 例如 我要十组数组里面随机找2个不同的 合并在一起 例如
a*b 1&3 1&2 1&1 1&a 1&b
*****当然还有很多
怎么匹配这样的数字呢? 展开
a{1,2,3,4,5}
b{3,2,1,a,b}
c{d,f,r,e,x,c}
d{b,t,y,h,g}
e{b,d,r}
f{0,23,15,06,05}
......
一共十组 我怎么匹配 例如 我要十组数组里面随机找2个不同的 合并在一起 例如
a*b 1&3 1&2 1&1 1&a 1&b
*****当然还有很多
怎么匹配这样的数字呢? 展开
展开全部
我做了个三个的。剩下的就是加数组了。你可以自己看看。
cs段
public partial class Default5 : System.Web.UI.Page
{
string[] a = new string[5] { "1", "2", "3", "4", "5" };
string[] b = new string[5] { "a", "b", "c", "d", "e" };
string[] c = new string[5] { "m", "j", "k", "l", "v" };
protected void Page_Load(object sender, EventArgs e)
{
Panel pl;
TextBox lb;
Label lbb;
string txt;
txt = "";
for (int i = 0; i < 5; i++) {
//lb = new Label();
txt += a[i] + ",";
}
lb = new TextBox();
lb.Text = txt;
pl = new Panel();
pl.Controls.Add(lb);
lbb = new Label();
lbb.Text = "数组a包含有:";
div_random.Controls.Add(lbb);
div_random.Controls.Add(pl);
txt = "";
for (int i = 0; i < 5; i++)
{
//lb = new Label();
txt += b[i] + ",";
}
lb = new TextBox();
lb.Text = txt;
pl = new Panel();
pl.Controls.Add(lb);
lbb = new Label();
lbb.Text = "数组b包含有:";
div_random.Controls.Add(lbb);
div_random.Controls.Add(pl);
txt = "";
for (int i = 0; i < 5; i++)
{
//lb = new Label();
txt += c[i] + ",";
}
lb = new TextBox();
lb.Text = txt;
pl = new Panel();
pl.Controls.Add(lb);
lbb = new Label();
lbb.Text = "数组b包含有:";
div_random.Controls.Add(lbb);
div_random.Controls.Add(pl);
}
protected void Button3_Click(object sender, EventArgs e)
{
int n = new System.Random().Next(4) ;
int m = new System.Random().Next(4) ;
int k = new System.Random().Next(4);
TextBox2.Text = a[n] + "," + b[m] + "," + c[k];
}
}
aspx段
<div id="div_random" runat="server" style=" margin-top:50px;">
</div>
<div>
<br />
<asp:Button ID="Button3" runat="server" Text="随机抽取两个元素进行组合"
onclick="Button3_Click" />
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
cs段
public partial class Default5 : System.Web.UI.Page
{
string[] a = new string[5] { "1", "2", "3", "4", "5" };
string[] b = new string[5] { "a", "b", "c", "d", "e" };
string[] c = new string[5] { "m", "j", "k", "l", "v" };
protected void Page_Load(object sender, EventArgs e)
{
Panel pl;
TextBox lb;
Label lbb;
string txt;
txt = "";
for (int i = 0; i < 5; i++) {
//lb = new Label();
txt += a[i] + ",";
}
lb = new TextBox();
lb.Text = txt;
pl = new Panel();
pl.Controls.Add(lb);
lbb = new Label();
lbb.Text = "数组a包含有:";
div_random.Controls.Add(lbb);
div_random.Controls.Add(pl);
txt = "";
for (int i = 0; i < 5; i++)
{
//lb = new Label();
txt += b[i] + ",";
}
lb = new TextBox();
lb.Text = txt;
pl = new Panel();
pl.Controls.Add(lb);
lbb = new Label();
lbb.Text = "数组b包含有:";
div_random.Controls.Add(lbb);
div_random.Controls.Add(pl);
txt = "";
for (int i = 0; i < 5; i++)
{
//lb = new Label();
txt += c[i] + ",";
}
lb = new TextBox();
lb.Text = txt;
pl = new Panel();
pl.Controls.Add(lb);
lbb = new Label();
lbb.Text = "数组b包含有:";
div_random.Controls.Add(lbb);
div_random.Controls.Add(pl);
}
protected void Button3_Click(object sender, EventArgs e)
{
int n = new System.Random().Next(4) ;
int m = new System.Random().Next(4) ;
int k = new System.Random().Next(4);
TextBox2.Text = a[n] + "," + b[m] + "," + c[k];
}
}
aspx段
<div id="div_random" runat="server" style=" margin-top:50px;">
</div>
<div>
<br />
<asp:Button ID="Button3" runat="server" Text="随机抽取两个元素进行组合"
onclick="Button3_Click" />
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
更多追问追答
追问
你好,非常感谢你的回答,你的答案给了我很大的帮助,但是我不是取随机的,我是要做到,查询一共能匹配多少个。并不是随机取出来,看看那些匹配出来,并且罗列出来。
你好,非常感谢你的回答,你的答案给了我很大的帮助,但是我不是取随机的,我是要做到,查询一共能匹配多少个。并不是随机取出来,看看那些匹配出来,并且罗列出来。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询