e chạy đc mà nó cứ đến đoạn Lietke là dừng chương trình ạ , e cảm ơn .
#include<iostream>
#include <conio.h>
#include <string.h>
#include<fstream>
using namespace std;
struct Dausach{
string TenSach,TacGia,TheLoai;
int SoTrang,NamSx ,ISBN;
};
struct node{
Dausach d;
node *next;
};
struct List{
node *First ;
node *Last ;
};
void KhoiTao(List & l){
l.First =l.Last =NULL;
}
node * getNode(Dausach &ds ){
node *p =new node ;
if(p==NULL){
return NULL ;
}
p->d=ds;
p->next=NULL;
return p ;
}
node * Search(List l, int x)
{
for (node * p = l.First; p != NULL ; p=p->next )
if ( p->d.ISBN == x ) return p;
return NULL;
}
void NhapDs (Dausach & ds) {
List l;
node * p ;
NhapLai:
cout<<"Nhap ISBN :";
cin>>ds.ISBN;
if(ds.ISBN<=0){
cout <<"Ma ISBN khong hop le ! Xin nhap lai"<<endl ;
goto NhapLai ;
}
if(Search(l ,ds.ISBN)){
cout<<"Ma ISBN bi trung .Xin nhap lai !";
cout<<endl;
goto NhapLai ;
}
fflush (stdin);
cout << "\nTen sach :" ;
fflush (stdin);
getline(cin,ds.TenSach);
cout << "\nTac gia :" ;
fflush (stdin);
getline(cin,ds.TacGia);
cout << "\nThe Loai :" ;
fflush (stdin);
getline(cin,ds.TheLoai);
cout<<"\nNhap So Trang :";
cin>>ds.SoTrang;
cout<<"\nNhap Nam San Xuat :";
cin>>ds.NamSx;
p = new node ;
p->d = ds ; p->next=NULL;
}
void LietKe (List l ) {
node * r = l.First ;
int dem =1 ;
if (r==NULL){
cout<<"danh sach rong ! ";
}
else while(r!=NULL){
cout<<"\n ------------------------------------------";
cout<<"\n | Sach thu: "<<dem ++<<" |";
cout<<"\n ------------------------------------------";
cout<<"\n Ma ISBN : "<<r->d.ISBN ;
cout<<"\n Ten Sach: "<<r->d.TenSach;
cout<<"\n Tac Gia : "<<r->d.TacGia;
cout<<"\n The Loai: "<<r->d.TheLoai;
cout<<"\n SO Trang: "<<r->d.SoTrang;
cout<<"\n Nam Xuat Ban: "<<r->d.NamSx;
r=r->next;
cout<<"\n ------------------------------------------";
}
}
int Menu(){
int c ;
cout<<endl<<endl <<endl <<" Chuc nang cua chuong trinh "<<endl;
cout<<" ----------------------------------------------------------------"<<endl;
cout<<" | 0 : Thoat. |"<<endl;
cout<<" | 1 : Nhap doc gia. |"<<endl;
cout<<" | 2 : Xuat danh sach doc gia . |"<<endl;
cout<<" | 3 : Nhap dau sach. |"<<endl;
cout<<" | 4 : Xuat danh sach sach. |"<<endl;
cout<<" | 5 : Tim Sach. |"<<endl;
cout<<" | 6 : Muon sach. |"<<endl;
cout<<" | 7 : Tra sach. |"<<endl;
cout<<" | 8 : Danh sach sach doc gia dang muon. |"<<endl;
cout<<" | 9 : Danh sach doc gia muon sach qua han. |"<<endl;
cout<<" | 10: 10 cuon sach co nhieu nguoi muon nhat. |"<<endl;
cout<<" ----------------------------------------------------------------"<<endl;
cout<<"Ban chon : ";
cin>>c;
return c;
}
int main() {
List l ;
Dausach ds;
NhapDs (ds) ;
LietKe(l);
return 0 ;
}