Mn cho mk hỏi em làm sai chỗ nào mà xuất ra hiển thị sai ạ
#include<iostream>
#include<string.h>
using namespace std;
struct sinhvien{
string tensv;
char masv[50];
char malop[50];
int ns;
string qq;
};
typedef struct sinhvien sv;
struct node{
sv data;
struct node *next;
};
typedef struct node NODE;
struct list{
NODE *pHead;
NODE *pTail;
};
typedef struct list LIST;
void khoitaodslk(LIST &l){
l.pHead=l.pTail=NULL;
}
NODE *taonode(sv x){
NODE *p =new NODE;
if(p==NULL){
cout<<"Kh du bo nho de cap phat!";
return NULL;
}
p->data = x;
p->next = NULL;
return p;
}
void chencuoi(LIST &l,NODE *p){
if(l.pHead==NULL){
l.pHead=l.pTail=p;
}
else{
l.pTail->next=p;
l.pTail=p;
}
}
void duyetds(LIST l){
cout <<"---THONG TIN SV SAU KHI NHAP---:";
int i=1;
for(NODE *p=l.pHead;p!=NULL;p=p->next){
cout<<"\nThong tin sinh vien"<<i<<endl;
i++;
cout<<"\nHo ten:"<<p->data.tensv;
cout<<"\nMA SV:"<<p->data.masv;
cout<<"\nMalop:"<<p->data.malop;
cout<<"\nNam sinh:"<<p->data.ns;
cout<<"\nQue quan:"<<p->data.qq;
}
}
int main(){
LIST l;
khoitaodslk(l);
int n;
cout<<"NHAP SO LUONG SV:";
cin>>n;
for(int i=1;i<=n;i++){
sv x;
cout <<"\n--NHAP THONG TIN SV "<<i<<endl;
cout<<"\nNhap ho ten:";
fflush(stdin);
//cin>>x.tensv;
getline(cin,x.tensv);
cout<<"\nNhap ma sinh vien:"<<endl;
fflush(stdin);
cin>>x.masv;
cout<<"\nNhap ma lop:"<<endl;
fflush(stdin);
cin>>x.malop;
cout<<"\nNhap nam sinh:"<<endl;
fflush(stdin);
cin>>x.ns;
cout<<"\nNhap que quan:"<<endl;
fflush(stdin);
//cin>>x.qq;
getline(cin,x.qq);
NODE *p= new NODE;
chencuoi(l,p);
}
duyetds(l);
system("pause");
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?