#include #include #include #include struct DATE { int ngay, thang, nam; }; struct SV { char MSSV [15]; char hoTen [50]; DATE ns; float diemTB; }; void nhap1SV (SV &x); void nhapDSSV (SV x[], int &n); void xuatDSSV (SV x[], int n); void timThongTinTheoMSSV (SV x[], int n); void suaDiem(SV x[], int n); void sapXepTheoMSSV(SV x[], int n); void sapXepTheoDTB(SV x[], int &n); void timAvaXoaTheoMSSV (SV x[], int &n, char MaSo[]); int docFile(SV x[], int n, char fileName[]); void ghiFile(SV x[], int n, char fileName[]); int main() { SV x[15]; int n, chon; char maMuonXoa [15]; char fileName[] = "BT_Nhom.txt"; while (true) { printf("\n\t----CHUONG TRINH QUAN LY SINH VIEN C----"); printf("\n\t 1. Doc danh sach SV cua file"); printf("\n\t 2. Nhap danh sach SV"); printf("\n\t 3. Xuat danh sach SV"); printf("\n\t 4. Sua diem cua mot SV bat ky"); printf("\n\t 5. Tim kiem thong tin SV dua vao viec nhap MSSV"); printf("\n\t 6. Sap xep SV theo MSSV"); printf("\n\t 7. Sap xep thu hang SV theo DTB"); printf("\n\t 8. Xoa SV ra khoi danh sach dua tren MSSV"); printf("\n\t 9. Ghi danh sach SV vao file"); printf("\n\t 0. Thoat. "); printf("\n\t--------------------------------------------------"); printf("\n\nNhap tuy chon: "); fflush(stdin); scanf("%d", &chon); switch(chon) { case 1: printf("\n\t 1. DOC DANH SACH SINH VIEN"); docFile(x, n, fileName); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 2: printf("\n\t 2. NHAP DANH SACH SV\n"); do { printf("\nNhap so luong SV (015); printf("\n\tNHAP DANH SACH SV"); nhapDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 3: printf("\n\t 3.XUAT DANH SACH SV\n"); xuatDSSV(x,n); printf("\n\nNhap them thong tin SV bang cach nhap tuy chon 1"); printf(" hoac nhap tuy chon 9 de doc DSSV co san tu file."); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 4: printf("\n\t 4. SUA DIEM CUA MOT SINH VIEN BAT KY\n"); suaDiem(x,n); xuatDSSV(x,n); printf("\n\nNhap them thong tin SV bang cach nhap tuy chon 1"); printf(" hoac nhap tuy chon 9 de doc DSSV co san tu file."); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 5: printf("\n\t 5. TIM KIEM THONG TIN SV DUA VAO VIEC NHAP MSSV\n"); timThongTinTheoMSSV(x,n); // xuatDSSV(x,n); printf("\n\nNhap them thong tin SV bang cach nhap tuy chon 1"); printf(" hoac nhap tuy chon 9 de doc DSSV co san tu file."); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 6: printf("\n\t 6. SAP XEP SV THEO MSSV\n"); sapXepTheoMSSV(x,n); xuatDSSV(x,n); printf("\n\nNhap them thong tin SV bang cach nhap tuy chon 1"); printf(" hoac nhap tuy chon 9 de doc DSSV co san tu file."); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 7: printf("\n\t 7. SAP XEP THU HANG SV THEO DTB\n"); sapXepTheoDTB(x,n); xuatDSSV(x,n); printf("\n\nNhap them thong tin SV bang cach nhap tuy chon 1"); printf(" hoac nhap tuy chon 9 de doc DSSV co san tu file."); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 8: printf("\n\t 8. XOA SV RA KHOI DS DUA TREN MSSV\n"); timAvaXoaTheoMSSV(x,n,maMuonXoa); printf("\n"); xuatDSSV(x,n); printf("\n\nNhap them thong tin SV bang cach nhap tuy chon 1"); printf(" hoac nhap tuy chon 9 de doc DSSV co san tu file."); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); break; case 9: printf("\n\t 9. GHI DANH SACH SINH VIEN VAO FILE\n"); ghiFile(x,n,fileName); printf("\nGhi danh sach sinh vien vao file %s thanh cong!", fileName); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 0: printf("\nBan da chon thoat chuong trinh!"); getch(); return 0; default: printf("\nKhong co chuc nang nay!"); printf("\nHay chon chuc nang hop le!"); break; } } return 1; } void nhap1SV (SV &x) { printf("\nMSSV: "); fflush (stdin); scanf("%s", &x.MSSV); printf("Ho ten: "); fflush (stdin); gets(x.hoTen); printf("Ngay/thang/nam sinh (.../.../...): "); scanf("%02d %*c %02d %*c %4d", &x.ns.ngay, &x.ns.thang, &x.ns.nam); printf("Diem TB: "); scanf("%f", &x.diemTB); } void nhapDSSV (SV x[], int &n) { fflush(stdin); for(int i=0; i 0) { a = x[i]; x[i] = x[j]; x[j] = a; } } void sapXepTheoDTB(SV x[], int &n) { SV tmp; int i, j; for (i=0; i