日期:2014-05-18 浏览次数:20840 次
private void button1_Click(object sender, EventArgs e) { int t = Convert.ToInt32(textBox1.Text);//获取输入的数字 List<int> lInt = new List<int>(); for (int i = 1; i <= t; i++) lInt.Add(i); lInt = js(1, 0, lInt);//运算 foreach (int v in lInt) { textBox2.Text += v + "\t";//输出结果 } }
/// <summary> /// /// </summary> /// <param name="i">报数</param> /// <param name="index">value下标</param> /// <param name="value"></param> /// <returns></returns> private List<int> js(int i, int index, List<int> value) { if (value.Count < 3) return value; if (i == 3) { value.RemoveAt(index); return js(i++, index, value); } else { index++; if (index >= value.Count) index = 0; return js(i++, index, value); } }