日期:2014-05-17 浏览次数:20782 次
namespace 客栈二面摇号程序 { public partial class 客栈二面摇号程序 : Form { public 客栈二面摇号程序() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int number =Convert.ToInt32(textBox1.Text); int groups =4; label1.Text = "请按小组顺序入座"; string[] strArr = Group(number, groups); for (int i = 0; i < strArr.Length; i++) { label2.Text += "第" + (i + 1) + "组 " + strArr[i]; } } static string[] Group(int number, int groups) { List<int> list = new List<int>(); int num = number / 4; string[] strArr = new string[groups]; for (int i = 1; i <= number; i++) list.Add(i); for (int i = 0; i < groups; i++) { for (int j = 0; j < num; j++) { int value = list[new Random().Next(0, list.Count)]; list.Remove(value); strArr[i] += value.ToString("D2") + " "; } } return strArr; } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; label2.Text = ""; } }