ko the chay dc chuong trinh
Mã:
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
#include<stream.h>
typedef struct TaiKhoan
{
int Ma;
char Ten;
char CMND;
double Tien;
}TK;
typedef struct node
{
TK data;
node *next;
};
struct list
{
node *head;
node *tail;
};
node *getnode(TK tk)
{
node *p;
p=new(node);
if(p==NULL)
{
printf("
khong du bo nho");
return NULL;
}
p->data=tk;
p->next=NULL;
return p;
}
int taoList(list &l)
{
l.head=l.tail=NULL;
}
int themdau(list &l,node *p)
{
if(l.head==NULL)
{
l.head=l.tail=p;
}
else
{
p->next=l.head;
l.head=p;
}
}
node* chendau(list &l,TK x)
{
node*p=getnode(x);
if(p==NULL)
return NULL;
if(l.head==NULL)
{
l.head=p;
l.tail=l.head;
}
else
{
p->next=l.head;
l.head=p;
}
return p;
}
node* tim(list &l,int &key)
{
node*p;
p=l.head;
while(p!=NULL&&p->data.Ma!=key)
{
if(p->data.Ma==key)
return p;
else
p->next;
}
}
int xoaDS(list &l)
{
node*p;
p=l.head;
while(p!=NULL)
{
delete p;
p->next;
}
}
int xoaKH(list &l,int key)
{
cout<<"nhap so ma tk";
cin>>key;
node*p;
p=tim(l,key);
delete p;
}
int in(node*p)
{
cout<<"-------------------------------------------------------------";
cout<<"Ma So TK tai khoan:"<<p->data.Ma;
cout<<"Ho va Ten chu TK:"<<p->data.Ten;
cout<<"So CMND cua chu TK:"<<p->data.CMND;
cout<<"So tien trong TK:"<<p->data.Tien;
}
int inDS(list &l)
{
node*p;
p=l.head;
while (p!=NULL)
{
in(p);
p->next;
}
}
int inKH(list &l,int key)
{
cout<<"nhap so ma tk";
cin>>key;
node*p;
p=tim(l,key);
in(p);
}
int nhap(list &l)
{
node*p;
TK tk;
cout<<"Nhap Ma tai khoan";cin>>(p->data.Ma);
cout<<"Nhap Ten tai khoan";cin>>(p->data.Ten);
cout<<"Nhap CMND tai khoan";cin>>(p->data.CMND);
cout<<"Nhap Tien tai khoan";cin>>(p->data.Tien);
p=getnode(tk);
}
int nhapTK(list &l,node* x)
{
int n;
cout<<"nhap so luong tai khoan";
cin>>n;
for (int i=0;i<n;i++)
{
nhap(l,x);
themdau(l,x);
}
}
int main()
{
TK x;
list l;
node*p;
int chon;
do
{
cout<<"
=====MENU======";
cout<<"
0.THOAT ";
cout<<"
1.NHAP TK ";
cout<<"
2.XEM LIST TK";
cout<<"
3.XEM 1 TK ";
cout<<"
4.XOA DS ";
cout<<"
5.XOA 1 TK ";
cout<<"
Moi Ban Chon : ";
cin>>chon;
switch(chon)
{
case 1: nhapTK;
case 2: inDS;
case 3: inKH;
case 4: xoaDS;
case 5: xoaKH;
}
}
while(chon!=0);
}
View more random threads:
Không chỉ dừng lại ở việc sử dụng nguyên liệu cao cấp, mỗi công trình còn được "chăm sóc" bằng 4 dịch vụ xuất sắc của Tre Nghệ. Từ việc tư vấn, thiết kế đến thi công và hoàn thiện, mọi quy trình đều...
Chất Lượng và Sáng Tạo: Kiến Trúc...