Include
Include
h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
struct NgayThangNam {
int ngay;
int thang;
int nam;
};
struct LopHoc {
int maLop;
char tenLop[100];
char lichHoc[10];
double hocPhi;
struct LopHoc* Next;
};
struct HocVien {
int maHocVien;
char hoLot[50];
char ten[50];
struct NgayThangNam ngaySinh;
int maLop;
double diem;
struct HocVien* Next;
};
struct lophoc {
LopHoc* Head;
LopHoc* Tail;
};
struct hocvien {
HocVien* Head;
HocVien* Tail;
};
LopHoc *createlophoc(int ma, char ten[], char lich[], double hocphi){
LopHoc *p = (struct LopHoc*)malloc(sizeof(struct LopHoc));
if (p == NULL){
printf("khong the cap phat node moi");
getch();
return NULL;
}
p->maLop = ma;
strcpy(p->tenLop, ten);
strcpy(p->lichHoc, lich);
p->hocPhi = hocphi;
p->Next = NULL;
return p;
}
HocVien *createhocvien(int ma, char hoLot[], char ten[], struct NgayThangNam
ngaySinh, int maLop, double diem){
HocVien *p = (struct HocVien*)malloc(sizeof(struct HocVien));
if (p == NULL){
printf("khong the cap phat node moi");
getch();
return NULL;
}
p->maHocVien = ma;
strcpy(p->hoLot, hoLot);
strcpy(p->ten, ten);
p->ngaySinh = ngaySinh;
p->maLop = maLop;
p->diem = diem;
p->Next = NULL;
return p;
}
void initlophoc(lophoc &lp){
lp.Head = NULL;
lp.Tail = NULL;
}
void inithocvien(hocvien &hv){
// khởi tạo danh sách rỗ ng
hv.Head = NULL;
hv.Tail = NULL;
}
int isEmptylophoc(lophoc lh){
if (lh.Head == NULL){
return 1;
}
else{
return 0;
}
}
int isEmptyhocvien(hocvien hv){
// kiểm tra danh sách rỗ ng
if (hv.Head == NULL){
return 1;
}
else{
return 0;
}
}
int themvaoLopHoc(lophoc &lh, LopHoc *p){
if (p == NULL){
return 0;
}
if (isEmptylophoc(lh) == 1){
lh.Head = p;
lh.Tail = p;
}
else{
p->Next = lh.Head;
lh.Head = p;
}
return 1;
}
int themvaoHocVien(hocvien &hv, HocVien *p){
if (p == NULL){
return 0;
}
if (isEmptyhocvien(hv) == 1){
hv.Head = p;
hv.Tail = p;
}
else{
p->Next = hv.Head;
hv.Head = p;
}
return 1;
}
void themLopHoc(lophoc &lh) {
int ma;
char ten[100];
char lich[10];
double hocphi;
printf("Nhap ma lop: ");
scanf("%d", &ma);
printf("Nhap ten lop: ");
scanf("%s", ten);
printf("Nhap lich hoc: ");
scanf("%s", lich);
printf("Nhap hoc phi: ");
scanf("%lf", &hocphi);
switch (chon){
case 1:
break;
case 2:
break;
case 3:
themHocVien(dsHocVien);
showdanhsachhocvien(dsHocVien);
break;
case 4:
int luachon4;
printf("\
n**************************************************************************\n");
printf("\n Lua chon 4
\n");
printf("\
n**************************************************************************\n");
printf("\n 1. Tim kiem theo ten lop
\n");
printf("\n 2. Tim kiem theo ma hoc vien
\n");
printf("\n 3. Tim kiem theo nam sinh
\n");
printf("\
n**************************************************************************\n");
printf("\nBan hay lua chon chuc nang: ");
scanf("%d", &luachon4);
switch (luachon4){
case 1:
case 2:
int ID;
printf("\nnhap ma hoc sinh ma ban can tim: ");
scanf("%d", &ID);
timkiemtheomahs(dsHocVien, ID);
break;
case 3:
int NAM;
printf("\nnhap nam sinh cua hoc sinh ma ban can tim: ");
scanf("%d", &NAM);
timkiemtheonamsinh(dsHocVien, NAM);
}
break;
case 5:
break;
case 6:
break;
case 7:
break;
}
} while (chon != 0);
getch();
}
int main() {
process();
getch();
}