LinkedList code em k xuất được ạ mọi người giúp em sửa lỗi với
#include <iostream>
#include <list>
#include <string>
using namespace std;
struct Video
{
string sTenPhim, sTheLoai, sTenDaoDien, sTenDVNamChinh, sTenDVNuChinh, sHangSX;
int nNamSX;
};
struct Node
{
Video Data;
Node *pNext;
};
struct LinkedList
{
Node* pHead;
Node* pTail;
LinkedList()
{
pHead = NULL;
pTail = NULL;
}
};
Node* CreateNode(Video VD)
{
Node* p = new Node;
if(p == NULL)
{
return NULL;
}
p->Data = VD;
p->pNext = NULL;
return p;
}
void addTail(LinkedList l, Node* pNew);
void nhapDSVideo(Video &VD);
void xuatDSVideo(Video VD);
Node* CreateNode(Video VD);
void nhapDSNode(LinkedList &l, Video &VD);
void xuatDSNode(LinkedList l);
void main()
{
LinkedList l;
Video VD;
nhapDSNode(l,VD);
xuatDSNode(l);
system("pause");
}
void xuatDSNode(LinkedList l)
{
for(Node* p =l.pHead; p != NULL; p = p->pNext)
{
xuatDSVideo(p->Data);
}
}
void nhapDSNode(LinkedList &l, Video &VD)
{
int nN = 0;
cout <<" Nhap so luong phim trong danh sach: ";
cin >> nN;
for(int i = 0; i < nN; i++)
{
nhapDSVideo(VD);
Node* p = CreateNode(VD);
addTail(l,p);
}
}
void addTail(LinkedList l, Node* pNew)
{
if(l.pHead == NULL)
{
l.pHead = pNew;
l.pTail = pNew;
}
else
{
l.pTail->pNext = pNew;
l.pTail = pNew;
}
}
void xuatDSVideo(Video VD)
{
cout <<" Ten phim: " << VD.sTenPhim << endl;
cout <<" The loai: " << VD.sTheLoai << endl;
cout <<" Ten dao dien: " << VD.sTenDaoDien << endl;
cout <<" Ten nam chinh: " << VD.sTenDVNamChinh << endl;
cout <<" Ten nu chinh: " << VD.sTenDVNuChinh << endl;
cout <<" Nam san xuat: " << VD.nNamSX << endl;
cout <<" Hang san xuat: " << VD.sHangSX << endl;
cout <<"-----------------------------------------------------------------------" << endl;
}
void nhapDSVideo(Video &VD)
{
int nLoai = 0;
cout <<" Nhap ten phim: ";
rewind(stdin);
getline(cin, VD.sTenPhim);
cout <<" Cac the loai: "<< endl;
cout <<"\t\t 1: Hinh su \t 2: Tinh cam \t 3:Hai" << endl;
cout <<"\tChon the loai: ";
cin >> nLoai;
if(nLoai == 1)
{
VD.sTheLoai = "Hinh su";
}
else if(nLoai == 2)
{
VD.sTheLoai = "Tinh cam";
}
else
{
VD.sTheLoai = "Hai";
}
cout <<" Nhap ten dao dien: ";
rewind(stdin);
getline(cin, VD.sTenDaoDien);
cout <<" Nhap ten dien vien nam chinh: ";
rewind(stdin);
getline(cin, VD.sTenDVNamChinh);
cout <<" Nhap ten dien vien nu chinh: ";
rewind(stdin);
getline(cin, VD.sTenDVNuChinh);
cout <<" Nhap nam san xuat: ";
cin >> VD.nNamSX;
cout <<" Nhap ten hang phim: ";
rewind(stdin);
getline(cin, VD.sHangSX);
}