找传奇、传世资源到传世资源站!

C# WindowsForms简单程序; 生成一组双色球随机号码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

C# WindowsForms简单程序;  生成一组双色球随机号码。入门级窗口程序,告别枯燥的DOS界面。C# WindowsForms简单程序;  生成一组双色球随机号码 C#语言基础-第1张using System;using System.Windows.Forms;namespace 双色球WindowsForms{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int[] red = new int[6]; Random s = new Random(); //从1~33中生成6个不重复的随机数红球; for (int i = 0; i < 6; i ) { int a = s.Next(1, 34), j; for (j = 0; j < i; j ) { if (a == red[j]) { i--; break; } } red[j] = a; } //为生成的红球按从小到大排序; for (int i = 0; i < 6; i ) { for (int j = i; j < 5; j ) { if (red[i] > red[j 1]) { int 中间变量 = red[i]; red[i] = red[j 1]; red[j 1] = 中间变量; } } } textBox1.Text = red[0].ToString(); textBox2.Text = red[1].ToString(); textBox3.Text = red[2].ToString(); textBox4.Text = red[3].ToString(); textBox5.Text = red[4].ToString(); textBox6.Text = red[5].ToString(); //从1~16中生成1个随机数篮球; int blue = s.Next(1, 17); textBox7.Text = blue.ToString(); } //清空内容; private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复