Code của em sai ở đâu mà em k xuất ra được ạ. Em cảm ơn
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std ;
struct Sinh_vien
{
string Name ;
string Class ;
int Age ;
};
typedef struct Sinh_vien sv ;
struct node
{
sv data ;
struct node *next ;
};
typedef struct node NODE ;
struct list
{
NODE *head ;
NODE *tail ;
};
typedef struct list LIST ;
void Khoi_tao(LIST &l)
{
l.head = NULL ;
l.tail = NULL ;
}
NODE *Khoi_tao_node(sv x)
{
NODE *p = new NODE ;
p->data = x ;
p->next = NULL ;
return p ;
}
void Addtail(LIST &l, NODE *p)
{
if(l.head == NULL)
{
l.head = l.tail = NULL ;
}
else
{
l.tail->next = p ;
l.tail = p ;
}
}
void Xuat(LIST &l, sv a)
{
for (NODE *k = l.head; k != NULL; k = k->next)
{
cout << "ten sv: " << k->data.Name ;
cout << "lop: " << k->data.Class ;
cout << "tuoi: " << k->data.Age ;
}
}
int main ()
{
sv a ;
LIST l ;
Khoi_tao(l);
int n ;
cout << "nhap so luong sinh vien: " ;
cin >> n ;
for (int i = 1; i <= n; i++)
{
fflush(stdin) ;
cout <<"\t\t=========THONG TIN SINH VIEN=============" ;
cout << "\nNhap ten sinh vien: " ;
getline(cin, a.Name) ;
cout << "Nhap lop sinh vien: " ;
getline(cin, a.Class) ;
cout << "Tuoi sinh vien: " ;
cin >> a.Age ;
NODE *p = Khoi_tao_node(a) ;
Addtail(l, p) ;
}
Xuat(l,a) ;
return 0 ;
}