Professional Documents
Culture Documents
EX04 NguyenAnhTu N20DCDT026
EX04 NguyenAnhTu N20DCDT026
- Code :
namespace DSLienKetDon
{
- Kết quả :
Thêm lần lượt các phần tử 1,2,3,4,5,6,8,9 vào danh sách.
Chèn phần tử 0 vào đầu danh sách :
public Form1()
{
InitializeComponent();
}
List<string> lotus = new List<string>();
node head;
node tail;
int size = 0;
public bool isempty()
{
return (size == 0);
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
int i = size;
int a = int.Parse(txtVa.Text);
node rose = new node(a, null);
if (isempty())
{
head = rose;
tail = head;
lotus.Add("Phan tu " + i + " : " + tail.data);
}
else
{
tail.next = rose;
tail = rose;
tail.next = head;
lotus.Add("Phan tu " + i + " : " + tail.data);
}
size += 1;
lstDs.Items.Clear();
lstDs.Items.AddRange(lotus.ToArray());
txtVa.Clear();
txtVa.Focus();
}
- Kết quả :
Thêm lần lượt các phần tử 1,2,3,4,5,6,8,9 vào danh sách.
public Form1()
{
InitializeComponent();
}
List<string> lotus = new List<string>();
node head;
node tail;
int size = 0;
public bool isempty()
{
return (size == 0);
}
- Kết quả :
Thêm lần lượt các phần tử 1,2,3,4,5,6,8,9 vào danh sách.
Chèn phần tử 0 vào đầu danh sách :