private void InsertBtn_Click(object sender, EventArgs e)//插入 { int i; string x, str; if (textBox4.Text.Trim() == "") { MessageBox.Show("操作提示:必须输入序号"); } else { try { i = Convert.ToInt16(textBox4.Text.Trim()); } catch (Exception err) { MessageBox.Show("操作提示:输入的序号是错误的"); return; } x = textBox5.Text.Trim(); if (x == "") { } else { if (L.ListInsert(i, x)) { str = L.DispList(); textBox8.Text = str; label5.Text = "插入结果"; textBox6.Text = L.ListLength().ToString(); label6.Text = "长度"; textBox4.Text = ""; textBox5.Text = ""; } else { textBox8.Text = ""; } } } }
private void Split(ref SqListClass L1, ref SqListClass L2)//输出奇偶顺序表 { int i = 1, j = 1, k = 1; string x = ""; while (k <= L.ListLength()) { L.GetElem(k, ref x); L1.ListInsert(i, x); i++; k++; if (k <= L.ListLength()) { L.GetElem(k, ref x); L2.ListInsert(j, x); j++; k++; } } MessageBox.Show("操作提示:成功产生两个顺序表"); }