You are on page 1of 4

/* quan li sinh vien bang danh sach lien ket */

#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <string.h>
typedefstruct
{
char ten[20];
char masv[20];
int tuoi;
}sinhvien;
typedefstruct sv
{
sinhvien info;
struct sv *next;
}!;
/* Viet luon cac ham */
void "nsert#head$! *first%sinhvien x&
{
! *tem';
tem'($! *&malloc$sizeof$!&&;
tem')>info(x;
tem')>(first;
first(tem';
}
void "nsert#last$! *first%sinhvien x &
{
! *ne*node;
! *tem';
ne*node($! *&malloc$sizeof$!&&;
ne*node)>info(x;
ne*node)>next(NULL;
tem'(first;
if$tem'+(NULL&
{
while$tem')>next+(NULL&
{
tem'(tem')>next;
}
tem')>next(ne*node;
}
else
first(ne*node;
}
void ,hoitao$! *first&
{
first(NULL;
}
void 'rint$! *first&
{
! *tem';
tem'(first;
if$tem'((NULL&
'rintf$-.n danh sach rong-&;
else
while$tem'+(NULL&
{
'rintf$-.n /en 0 1s -%tem')>info.ten&;
'rintf$-.n /uoi 0 1d-%tem')>info.tuoi&;
'rintf$-.n 2asv 0 1s -%tem')>info.masv&;
tem'(tem')>next;
}
getch$&;
}
void menu$! *first&
{
sinhvien x%3;
char c;
,hoitao$first&;
do
{
clrscr$&;
'rintf$-.n 4./hem vao dau danh sach -&;
'rintf$-.n 2./hem vao cuoi danh sach 0-&;
'rintf$-.n 5."n ra man hinh 0-&;
'rintf$-.n 0./6oat -&;
'rintf$-.n-&;
'rintf$-.n 7ha' vao lua chon 0 -&;
c(getch$&;
switch$c&
{
case8480
fflush$stdin&;
'rintf$-.n 7ha' vao ten0 -&;
gets$x.ten&;
'rintf$-.n 7ha' vao ma sinh vien -&;
gets$x.masv&;
'rintf$-.n 7ha' vao tuoi 0-&;
scanf$-1d-%9x.tuoi&;
"nsert#head$first%x&;
break;
case8280
fflush$stdin&;
'rintf$-.n 7ha' vao ten 0 -&;
gets$3.ten&;
'rintf$-.n 7ha' vao tuoi -&;
scanf$-1d-%93.tuoi&;
'rintf$-.n 7ha' vao ma sinh vien -&;
gets$3.masv&;
"nsert#last$first%3&;
break;
case8580'rintf$first&;
break;
case8080exit$4&;
break;
default0'rintf$-.n :an da nha' sai 'him chuc nang -&;
break;
}
}
while$c+(808&;
}
void main$&
{
! *first
menu$first&;
}
/* quan li sinh vien bang danh sach lien ket */
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <string.h>
typedefstruct
{
char ten[20];
char masv[20];
int tuoi;
}sinhvien;
typedefstruct sv
{
sinhvien info;
struct sv *next;
}!;
/* Viet luon cac ham */
void "nsert#head$! *first%sinhvien x&
{
! *tem';
tem'($! *&malloc$sizeof$!&&;
tem')>info(x;
tem')>(first;
first(tem';
}
void "nsert#last$! *first%sinhvien x &
{
! *ne*node;
! *tem';
ne*node($! *&malloc$sizeof$!&&;
ne*node)>info(x;
ne*node)>next(NULL;
tem'(first;
if$tem'+(NULL&
{
while$tem')>next+(NULL&
{
tem'(tem')>next;
}
tem')>next(ne*node;
}
else
first(ne*node;
}
void ,hoitao$! *first&
{
first(NULL;
}
void 'rint$! *first&
{
! *tem';
tem'(first;
if$tem'((NULL&
'rintf$-.n danh sach rong-&;
else
while$tem'+(NULL&
{
'rintf$-.n /en 0 1s -%tem')>info.ten&;
'rintf$-.n /uoi 0 1d-%tem')>info.tuoi&;
'rintf$-.n 2asv 0 1s -%tem')>info.masv&;
tem'(tem')>next;
}
getch$&;
}
void menu$! *first&
{
sinhvien x%3;
char c;
,hoitao$first&;
do
{
clrscr$&;
'rintf$-.n 4./hem vao dau danh sach -&;
'rintf$-.n 2./hem vao cuoi danh sach 0-&;
'rintf$-.n 5."n ra man hinh 0-&;
'rintf$-.n 0./6oat -&;
'rintf$-.n-&;
'rintf$-.n 7ha' vao lua chon 0 -&;
c(getch$&;
switch$c&
{
case8480
fflush$stdin&;
'rintf$-.n 7ha' vao ten0 -&;
gets$x.ten&;
'rintf$-.n 7ha' vao ma sinh vien -&;
gets$x.masv&;
'rintf$-.n 7ha' vao tuoi 0-&;
scanf$-1d-%9x.tuoi&;
"nsert#head$first%x&;
break;
case8280
fflush$stdin&;
'rintf$-.n 7ha' vao ten 0 -&;
gets$3.ten&;
'rintf$-.n 7ha' vao tuoi -&;
scanf$-1d-%93.tuoi&;
'rintf$-.n 7ha' vao ma sinh vien -&;
gets$3.masv&;
"nsert#last$first%3&;
break;
case8580'rintf$first&;
break;
case8080exit$4&;
break;
default0'rintf$-.n :an da nha' sai 'him chuc nang -&;
break;
}
}
while$c+(808&;
}
void main$&
{
! *first
menu$first&;
}

You might also like