nguyenducdh10th
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
Latest topics
» Transparency On Prices Required From All Health Care Sectors, Not Only Physicians, Letter States
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyWed Aug 03, 2011 4:48 pm by Khách viếng thăm

» Refog Kelogger wont work on machine with Net Protector Antivirus?
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyWed Aug 03, 2011 5:28 am by Khách viếng thăm

» play popular vegas slots
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyWed Aug 03, 2011 2:59 am by Khách viếng thăm

» fish oil heart health
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyTue Aug 02, 2011 11:48 pm by Khách viếng thăm

» hi i am using micromax 3g modem. i am clueless how to use it in Linux environment?
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyTue Aug 02, 2011 8:14 am by Khách viếng thăm

» гинекологические больницы отзывы
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyMon Aug 01, 2011 12:13 pm by Khách viếng thăm

» how i can made a backup of bootable USB.?
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptyMon Aug 01, 2011 2:48 am by Khách viếng thăm

» To which directory or path do we need to install the modules in drupal through filezilla?
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptySat Jul 30, 2011 9:29 pm by Khách viếng thăm

» Should I upgrade my hardware for my computer?
DANH SÁCH LIÊN KẾT BẰNG MẢNG EmptySat Jul 30, 2011 1:27 pm by Khách viếng thăm

Thống Kê
Hiện có 1 người đang truy cập Diễn Đàn, gồm: 0 Thành viên, 0 Thành viên ẩn danh và 1 Khách viếng thăm

Không

[ View the whole list ]


Số người truy cập cùng lúc nhiều nhất là 15 người, vào ngày Tue Apr 30, 2024 3:29 pm

DANH SÁCH LIÊN KẾT BẰNG MẢNG

Go down

DANH SÁCH LIÊN KẾT BẰNG MẢNG Empty DANH SÁCH LIÊN KẾT BẰNG MẢNG

Bài gửi  Admin Sat Apr 30, 2011 10:36 am

Chương trình bao gồm 2 lớp: các bạn coppy 2 lớp bên dưới về là chạy ngon lành luôn.
--------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CDanhSachLienKetBangMang
{
class CDanhSach
{
#region Các Field
int[] m_DS;
int m_Chieudai;
#endregion
#region Các Property
public int CHIEUDAY
{
get { return m_Chieudai; }
}
#endregion
#region Các Contructor
/// <summary>
/// Hàm dựng không đối số
/// </summary>
public CDanhSach()
{
m_DS=new int[100];
m_Chieudai = 0;
}
/// <summary>
/// Hàm dựng từ 1 danh sách có sẵn ds
/// </summary>
/// <param name="ds"></param>
public CDanhSach(CDanhSach ds)
{
m_DS = new int[100];
for (int chiso = 0; chiso <= ds.CHIEUDAY - 1; chiso++)
{
this.m_DS[chiso] = ds.m_DS[chiso];
}
this.m_Chieudai = ds.CHIEUDAY;
}

#endregion
#region Các Method
/// <1/ Hàm nhập Danh Sách>
///
/// </summary>
public void NhapDS()
{
bool ngung = false;
this.m_DS = new int[100];
this.m_Chieudai = 0;
Console.WriteLine("Moi ban nhap cac phan tu cho dang sach");
int sophantu = 0;
while (ngung == false)
{
int giatri;
try
{
Console.Clear();
sophantu += 1;
Console.Write("Moi ban nhap phan tu thu " + sophantu+": ");
giatri = int.Parse(Console.ReadLine());
this.m_Chieudai += 1;
this.m_DS[this.m_Chieudai - 1] = giatri;
}
catch
{
Console.Beep();
Console.WriteLine("Viec nhap ket thuc");
ngung = true;
}
}

}
/// <2/ In danh sách ra>
///
/// </summary>
public void InDS()
{

if (this.m_Chieudai == 0)
Console.WriteLine("Danh sach rong!");
else
{
try
{
for (int vitri = 0; vitri <= this.m_Chieudai - 1; vitri++)
{
Console.Write("|{0}|", this.m_DS[vitri]);
}
}
catch
{
Console.Beep();
Console.WriteLine("Danh Sach Rong!");
}
}
}
/// <3/ Chèn phần tử có giá trị x vào vị trí p trong danh sách>
///
/// </summary>
/// <param name="x"></param>
/// <param name="p"></param>
public void Chenxp(int x, int p)
{
if (p < 1 || p - 1 > this.m_Chieudai)
{
Console.Beep();
Console.WriteLine("Vi tri chen khong hop le");
}
else
{
m_Chieudai += 1;
// dời các phần tử từ vi trí p đến cuối mảng qua phải 1 phan tu
try
{
for (int vitri = m_Chieudai - 1; vitri > p - 1; vitri--)//p={1,2,3,4,...,n}, vitri={0,1,2,..n}
{
m_DS[vitri] = m_DS[vitri - 1];
}
// chèn x vào vi tri p
this.m_DS[p - 1] = x;
}
catch
{
Console.Beep();
Console.WriteLine("Vi tri chen khong hop le");
}
}
}
/// <4/ Chèn 1 phần tử x vào đầu danh sách>
///
/// </summary>
/// <param name="x"></param>
public void ChenDau(int x)
{
// thêm 1 phần tử mới
m_Chieudai+=1;
// dời tất cả các phần tử sang phai 1 ô
for (int vitri = m_Chieudai - 1; vitri > 0; vitri--)
{
m_DS[vitri] = m_DS[vitri - 1];
}
// chèn x vao dau danh sach
m_DS[0] = x;
}
/// <5/ Chèn 1 phần tử x vào cuối danh sách>
///
/// </summary>
/// <param name="x"></param>
public void ChenCuoi(int x)
{
// thêm 1 phần tử mới
this.m_Chieudai += 1;
//chèn x vào cuối danh sách
this.m_DS[m_Chieudai - 1] = x;
}
/// <6/ Xóa phần tử đầu danh sách>
///
/// </summary>
public void XoaDau()
{
for (int vitri = 0; vitri <= m_Chieudai - 1; vitri++)
m_DS[vitri] = m_DS[vitri + 1];
//giảm chiều dài 1 phần tử
m_Chieudai -= 1;
}
/// <7/ Xóa phần tử ở vị trí p>
///
/// </summary>
/// <param name="p"></param>
public void XoaViTriP(int p)
{
if (p < 1 || p > m_Chieudai)
{
Console.Beep();
Console.WriteLine("Vi tri xoa khong thuoc pham vi danh sach");
}
else
{
for (int vitri = p - 1; vitri <= m_Chieudai - 1; vitri++)
m_DS[vitri] = m_DS[vitri + 1];
m_Chieudai -= 1;
}
}
/// <8/ Xóa phần tử cuối của danh sách>
///
/// </summary>
public void XoaCuoi()
{
m_Chieudai -= 1;
}
/// <9/ Hàm sắp xếp danh sách nếu đối số bỏ vào la true thí sắp xếp tăng ngược lại sắp xếp giảm>
///
/// </summary>
/// <param name="tang"></param>
public void SapXepDS(bool tang)
{
if (tang == true) //xắp xếp tăng
{
for(int vitri=0;vitri<=m_Chieudai-2;vitri++)
for(int vitri1=vitri+1;vitri1<=m_Chieudai-1;vitri1++)
if (m_DS[vitri] > m_DS[vitri1])
{
int tam = m_DS[vitri];
m_DS[vitri] = m_DS[vitri1];
m_DS[vitri1] = tam;
}
}
else // xắp xếp giảm
{
for (int vitri = 0; vitri <= m_Chieudai - 2; vitri++)
for (int vitri1 = vitri + 1; vitri1 <= m_Chieudai - 1; vitri1++)
if (m_DS[vitri] < m_DS[vitri1])
{
int tam = m_DS[vitri];
m_DS[vitri] = m_DS[vitri1];
m_DS[vitri1] = tam;
}
}
}
/// <10/ Hàm trả về vị tri trí đầu tiên của x>
///
/// </summary>
/// <param name="x"></param>
/// <returns></returns>
public int ViTriDauX(int x)
{
int p=-1;
for (int vitri = 0; vitri <= m_Chieudai - 1; vitri++)
{
if (m_DS[vitri] == x)
{
p = vitri;
break;
}
}
return p+1;
}
/// <11/ Tách danh sách ra 2 danh sách chẵn và lẻ>
///
/// </summary>
/// <param name="dschan"></param>
/// <param name="dsle"></param>
public void TachDS(CDanhSach dschan, CDanhSach dsle)
{
for (int vitri = 0; vitri <= m_Chieudai - 1; vitri++)
{
if (m_DS[vitri] % 2 == 0) // nếu là chẵn
{
// chèn vào danh sách chẵn
dschan.ChenCuoi(m_DS[vitri]);
}
else // là lẽ
{
dsle.ChenCuoi(m_DS[vitri]);
}
}
}
/// <12/ Hàm trả về phần tử lớn nhất của danh sách>
///
/// </summary>
/// <returns></returns>
public int LonNhat()
{
int max=m_DS[0];
for (int vitri = 1; vitri <= m_Chieudai - 1; vitri++)
if (m_DS[vitri] > max)
max = m_DS[vitri];
return max;
}
/// <13/ Hàm in danh sách theo thứ tự ngược>
///
/// </summary>
/// <returns></returns>
public void InNguoc()
{
if (this.m_Chieudai <= 0)
{
Console.Beep();
Console.WriteLine("Danh sach rong!");
}
else
for (int vitri = m_Chieudai - 1; vitri >= 0; vitri--)
Console.Write("|{0}|", m_DS[vitri]);

}
/// <summary>
/// Kiểm tra danh sách có được sắp xếp chưa
/// - Chưa sắp xếp trả về 0
/// - Sắp xếp tăng trả vê 1
/// - Sắp xếp giảm trả về -1
/// </summary>
/// <returns></returns>
public int DaSapXep()
{
int sapxep = 0;
int vitri = 0;
for (int vt = 0; vt <= m_Chieudai - 2; vt++)
{
vitri = vt;
if (m_DS[vt] > m_DS[vt + 1])
break;
}
if (vitri == m_Chieudai - 2)// nếu dãy đã sắp xếp tăng
sapxep = 1;
else // kiểm tra có phải là dãy đã sắp xếp giảm không
{
for (int vt = 0; vt <= m_Chieudai - 2; vt++)
{
vitri = vt;
if (m_DS[vt] < m_DS[vt + 1])
break;
}
if (vitri == m_Chieudai - 2)
sapxep = -1;
else sapxep = 0;
}
return sapxep;

}
/// <14/ Hàm thêm phần tử x vào danh sách đã được sắp xếp>
///
/// </summary>
/// <param name="x"></param>
public void ThemPhanTuVaoDanhSachDaSapXep(int x)
{
if (this.DaSapXep() == 0) // danh sách chưa được sắp xếp
{
Console.WriteLine("Xin loi khong the chen duoc vi danh sach chua duoc săp xep!");
}
else// dãy được sắp xếp tăng hoặc giảm
{
if (this.DaSapXep() == 1)// Dãy đã được sắp xếp tăng
{
//tìm vi trí để chèn x vào

int vitrichen = -1;
for (int vitri = 0; vitri <= m_Chieudai - 2; vitri++)
if (m_DS[vitri] >= x)
{
vitrichen = vitri + 1;
break;
}
else
{
vitrichen = this.m_Chieudai+1;
}
this.Chenxp(x, vitrichen);
}
else // Dãy đã sắp xếp giảm
{
//tìm vi trí để chèn x vào
int vitrichen = -1;
for (int vitri = 0; vitri <= m_Chieudai - 1; vitri++)
if (m_DS[vitri] <= x)
{
vitrichen = vitri + 1;
break;
}
else
{
vitrichen = 1;
}
this.Chenxp(x, vitrichen);
}
}
}
/// <15/ Xóa phần tử trong danh sách được sắp xếp>
///
/// </summary>
/// <param name="x"></param>
public void XoaPhanTuTrongDanhSachDuocSapXep(int x)
{
if (this.DaSapXep() != 0)
{
// tìm vị trí của x
int p = -1;
for (int vitri = 0; vitri <= m_Chieudai - 1; vitri++)
if (m_DS[vitri] == x)
{
p = vitri + 1;
break;
}
try
{
this.XoaViTriP(p);
}
catch
{
Console.Beep();
Console.WriteLine(x + " khong ton tai nen khong the xoa!");
}
}
else
{
Console.Beep();
Console.WriteLine("Danh sach chua duoc sap xep nen khong the xoa");
}
}
/// <16/ Xóa các phần tử bị trùng lặp>
///
/// </summary>
public void XoaTrungLap()
{
for (int vitri = 0; vitri <= this.m_Chieudai - 2; vitri++)
{
int vt = vitri + 1;
while (vt <= this.m_Chieudai - 1)
{
if (this.m_DS[vitri] == this.m_DS[vt])
{
this.XoaViTriP(vt + 1);
}
else vt++;
}
}
}
/// <17/ Xóa các phần tử lẻ của danh sách>
///
/// </summary>
public void XoaPhanTuLe()
{
int vitri = 0;
while (vitri <= this.m_Chieudai - 1)
{
if (this.m_DS[vitri] % 2 != 0)
{
this.XoaViTriP(vitri + 1);
}
else vitri += 1;
}
}
/// <18/ Trộn 2 danh sách thành 1 danh sách>
///
/// </summary>
/// <param name="ds1"></param>
/// <param name="ds2"></param>
public void Tron2DanhSach(CDanhSach ds)
{
for (int vt = 0; vt <= ds.CHIEUDAY - 1; vt++)
{
this.m_Chieudai += 1;
this.m_DS[this.m_Chieudai - 1] = ds.m_DS[vt];
}
}
/// <summary>
/// Ghi danh sach vao file
/// </summary>



#endregion
}
}
-----------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CDanhSachLienKetBangMang
{
class Program
{
static void Main(string[] args)
{
CDanhSach ds = new CDanhSach();
CDanhSach ds1 = new CDanhSach();
CDanhSach ds2 = new CDanhSach();


string []thanhvien={"1. CAO VU BANG - MSSV: DTH09","2. BUI THANH DIEN - MSSV:DTH09","3. LE NGUYEN DUC - MSSV: DTH092032","4. DANG THI THAO LOAN - MSSV: DTH0920","5. NGUYEN DUY PHUONG - MSSV: DTH09","6. DOAN NHUT TRUNG - MSSV: DTH0920"};
int chon = 1;
while (chon != 0)
{
if (chon < 0 || chon > 17)
{
Console.Beep();
}
Console.Clear();
Console.WriteLine("DO AN MON CHUYEN DE NGON NGU LAP TRINH 3");
Console.WriteLine(" DE TAI SO 1");
Console.WriteLine("THANH VIEN:");
foreach (string ten in thanhvien)
{
Console.WriteLine(ten);
}
Console.WriteLine("----------------------------------------------------------------------------------------------------------------------");
menuchon: Console.Title = "Menu Cac Chuc Nang";
Console.WriteLine("00. Thoat Chuong Trinh");
Console.WriteLine("01. Nhap Danh Sach");
Console.WriteLine("02. Chen x Vao Vi Tri p Trong Danh Sach");
Console.WriteLine("03. Chen x Vao Dau Danh Sach");
Console.WriteLine("04. Chen x Vao Cuoi Danh Sach");
Console.WriteLine("05. Xoa Phan Tu O Dau Danh Sach");
Console.WriteLine("06. Xoa Phan Tu O Vi Tri P Cua Danh Sach");
Console.WriteLine("07. Xoa Phan Tu O Cuoi Danh Sach");
Console.WriteLine("08. Sap Xep Danh Sach");
Console.WriteLine("09. Vi Tri Dau Tien Cua X Trong Danh Sach");
Console.WriteLine("10. Tach Danh Sach Thanh Danh Sach Chan Va Le");
Console.WriteLine("11. Phan Tu Lon Nhat Trong Danh Sach");
Console.WriteLine("12. In Danh Sach Nguoc");
Console.WriteLine("13. Them X Vao Danh Sach Da Sap Xep");
Console.WriteLine("14. Xoa X Trong Danh Sach Da Sap Xep");
Console.WriteLine("15. Xoa Cac Phan Tu Trung Lap");
Console.WriteLine("16. Xoa Cac Phan Tu Le");
Console.WriteLine("17. Tron 2 Danh Sach");
Console.Write("Chon = ");
try
{

chon = int.Parse(Console.ReadLine());
}
catch
{
Console.Beep();
Console.Clear();
goto menuchon;
}
switch (chon)
{
#region 00. Thoat Chuong Trinh
case 0:
{
Console.Clear();
break;

}
#endregion
#region 01. Nhap Danh Sach
case 1:
{
Console.Title = "01. Nhap Danh Sach";
Console.Clear();
ds.NhapDS();
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 02. Chen x Vao Vi Tri p Trong Danh Sach
case 2:
{
Console.Title = "02. Chen x Vao Vi Tri p Trong Danh Sach";
int x, p;
Console.Clear();
xx:try
{
Console.Write("Nhap gia tri x can chen: ");
x = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("x la so. Vui long nhap lai! An enter de nhap lai!");
Console.ReadKey();
goto xx;
}
pp: try
{
Console.WriteLine("Nhap vi tri p can chen vao: ");
p = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("p la so. Vui long nhap lai! An enter de nhap lai.");
Console.ReadKey();
goto pp;
}
Console.Clear();
Console.WriteLine("Danh Sach Truoc Khi Chen "+x.ToString());
ds.InDS();
ds.Chenxp(x, p);
Console.WriteLine("\nDanh Sach Sau Khi Chen " + x.ToString());
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 03. Chen x Vao Dau Danh Sach
case 3:
{
Console.Title = "03. Chen x Vao Dau Danh Sach";
int x;
Console.Clear();
xx:try
{
Console.Write("Nhap x de chen vao dau danh sach: ");
x = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("X la so. An enter de nhap lai!");
Console.ReadKey();
goto xx;
}
Console.Clear();
Console.WriteLine("Danh Sach Truoc Khi Chen {0} Vao Dau Danh Sach",x);
ds.InDS();
ds.ChenDau(x);
Console.WriteLine("\nDanh Sach Sau Khi Chen {0} Vao Dau Danh Sach",x);
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 04. Chen x Vao Cuoi Danh Sach
case 4:
{
Console.Title = "04. Chen x Vao Cuoi Danh Sach";
int x;
Console.Clear();
xx: try
{
Console.Write("Nhap x de chen vao cuoi danh sach: ");
x = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("X la so. An enter de nhap lai!");
Console.ReadKey();
goto xx;
}
Console.Clear();
Console.WriteLine("Danh Sach Truoc Khi Chen {0} Vao Cuoi Danh Sach", x);
ds.InDS();
ds.ChenCuoi(x);
Console.WriteLine("\nDanh Sach Truoc Khi Chen {0} Vao Cuoi Danh Sach", x);
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 05. Xoa Phan Tu O Dau Danh Sach
case 5:
{
Console.Title = "05. Xoa Phan Tu O Dau Danh Sach";
Console.Clear();
Console.WriteLine("Danh Sach Truoc Khi Xoa Phan Tu Dau Tien");
ds.InDS();
ds.XoaDau();
Console.WriteLine("\nDanh Sach Sau Khi Xoa Phan Tu Dau Tien");
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 06. Xoa Phan Tu O Vi Tri P Cua Danh Sach
case 6:
{
Console.Title = "06. Xoa Phan Tu O Vi Tri P Cua Danh Sach";
Console.Clear();
int p;
pp:try
{
Console.Write("Nhap vi tri p can xoa: ");
p = int.Parse(Console.ReadLine());
}
catch
{
Console.Write("p la so. An Enter de nhap lai p!");
Console.ReadKey();
goto pp;
}
Console.Clear();
Console.WriteLine("Danh sach truoc khi xoa phan tu o vi tri {0}",p);
ds.InDS();
ds.XoaViTriP(p);
Console.WriteLine("\nDanh sach sau khi xoa phan tu o vi tri {0}", p);
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 07. Xoa Phan Tu O Cuoi Danh Sach
case 7:
{
Console.Clear();
Console.WriteLine("Danh sach truoc khi xoa phan tu cuoi");
ds.InDS();
ds.XoaCuoi();
Console.WriteLine("\nDanh sach sau khi xoa phan tu cuoi");
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 08. Sap Xep Danh Sach
case 8:
{
Console.Title = "08. Sap Xep Danh Sach";
int tang=-1;
int solannhap = 0;
while (tang!=1&&tang!=0)
{
Console.Clear();
Console.Write("Ban muon sap xep tang hay giam? tang/giam = 1/0: ");
try
{
tang = int.Parse(Console.ReadLine());
if (tang != 0 && tang != 1)
Console.Beep();
}
catch
{
Console.Beep();
}

}
Console.Clear();
Console.WriteLine("Danh sach truoc khi sap xep");
ds.InDS();
if (tang==1)
ds.SapXepDS(true);
else
ds.SapXepDS(false);
Console.WriteLine("\nDanh sach sau khi sap xep");
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 09. Vi Tri Dau Tien Cua X Trong Danh Sach
case 9:
{
Console.Title = "09. Vi Tri Dau Tien Cua X Trong Danh Sach";
int x;
Console.Clear();
xx: try
{
Console.Write("Nhap x de tim vi tri dau tien cua x trong danh sach: ");
x = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("X la so. An enter de nhap lai!");
Console.ReadKey();
goto xx;
}
Console.Clear();
Console.WriteLine("Danh sach");
ds.InDS();
if (ds.ViTriDauX(x) != 0)
Console.Write("\nVi tri dau tien cua x la: " + ds.ViTriDauX(x).ToString());
else Console.Write("\nKhong tim thay {0}", x);
Console.Read();
Console.Clear();
goto menuchon;
}
#endregion
#region 10. Tach Danh Sach Thanh Danh Sach Chan Va Le
case 10:
{
Console.Title = "10. Tach Danh Sach Thanh Danh Sach Chan Va Le";
Console.Clear();
CDanhSach dschan = new CDanhSach();
CDanhSach dsle = new CDanhSach();
Console.WriteLine("Danh Sach");
ds.InDS();
ds.TachDS(dschan, dsle);
Console.Write("\nDanh sach chan: ");
dschan.InDS();
Console.Write("\nDanh sach le: ");
dsle.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 11. Phan Tu Lon Nhat Trong Danh Sach
case 11:
{
Console.Title = "11. Phan Tu Lon Nhat Trong Danh Sach";
Console.Clear();
Console.WriteLine("Danh sach");
ds.InDS();
Console.Write("\nPhantu lon nhat trong danh sach la: " + ds.LonNhat().ToString());
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 12. In Danh Sach Nguoc
case 12:
{
Console.Title = "12. In Danh Sach Nguoc";
Console.Clear();
Console.WriteLine("Danh sach");
ds.InDS();
Console.WriteLine("\nDanh sach duoc in nguoc la");
ds.InNguoc();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 13. Them X Vao Danh Sach Da Sap Xep
case 13:
{
Console.Title = "13. Them X Vao Danh Sach Da Sap Xep";
int x;
Console.Clear();
xx: try
{
Console.Write("Nhap gia tri x can chen: ");
x = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("x la so. Vui long nhap lai! An enter de nhap lai!");
Console.ReadKey();
goto xx;
}
Console.WriteLine("Danh sach truoc khi chen {0}", x);
ds.InDS();
Console.WriteLine("\nDanh sach sau khi chen {0}", x);
ds.ThemPhanTuVaoDanhSachDaSapXep(x);
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 14. Xoa X Trong Danh Sach Da Sap Xep
case 14:
{
Console.Title = "14. Xoa X Trong Danh Sach Da Sap Xep";
int x;
Console.Clear();
xx: try
{
Console.Write("Nhap gia tri x can xoa: ");
x = int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("x la so. Vui long nhap lai! An enter de nhap lai!");
Console.ReadKey();
goto xx;
}
Console.WriteLine("Danh sach truoc khi xoa {0}",x);
ds.InDS();
ds.XoaPhanTuTrongDanhSachDuocSapXep(x);
Console.WriteLine("\nDanh sach sau khi xoa {0}", x);
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 15. Xoa Cac Phan Tu Trung Lap
case 15:
{
Console.Title = "15. Xoa Cac Phan Tu Trung Lap";
Console.Clear();
Console.WriteLine("Danh sach truoc khi xoa cac phan tu trung lap");
ds.InDS();
ds.XoaTrungLap();
Console.WriteLine("\nDanh sach sau khi xoa cac phan tu trung lap");
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 16. Xoa Cac Phan Tu Le
case 16:
{
Console.Title = "16. Xoa Cac Phan Tu Le";
Console.Clear();
Console.WriteLine("Danh sach truoc khi xoa cac phan tu le");
ds.InDS();
ds.XoaPhanTuLe();
Console.WriteLine("\nDanh sach sau khi xoa cac phan tu le");
ds.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
#region 17. Tron 2 Danh Sach
case 17:
{
Console.Title = "17. Tron 2 Danh Sach";
Console.Clear();
ds1.NhapDS();
ds2.NhapDS();
Console.Write("Danh sach thu 1: ");
ds1.InDS();
Console.Write("\nDanh sach thu 2: ");
ds2.InDS();
Console.WriteLine();
ds1.Tron2DanhSach(ds2);
Console.Write("Danh sach sau khi tron 2 danh sach: ");
ds1.InDS();
Console.ReadKey();
Console.Clear();
goto menuchon;
}
#endregion
}
}// end while
}//end main
}// end class program
}// end namespace CDanhSachLienKetBangMang
Admin
Admin
Admin

Tổng số bài gửi : 38
Join date : 20/11/2010

https://nguyenducdh10th.forumvi.com

Về Đầu Trang Go down

Về Đầu Trang

- Similar topics

 
Permissions in this forum:
Bạn không có quyền trả lời bài viết