Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void InPut(Lop s[], int &n)
- {
- do {
- printf("Nhap so luon can them: ");
- scanf_s("%d", &n);
- } while (n < 1);
- for (int i = 0; i < n; i++)
- {
- printf("1. Nhap ma lop");
- scanf_s("%d", &s[i].MaLop);
- rewind(stdin);
- printf("2. Nhap ten hoc phan");
- gets_s(s[i].TenHocPhan);
- printf("3. Nhap phong hoc");
- gets_s(s[i].PhongHoc);
- do {
- printf("4. Nhap ngay hoc trong tuan");
- scanf_s("%d", &s[i].NgayHoc);
- } while (s[i].NgayHoc < 2 && s[i].NgayHoc > 7);
- rewind(stdin);
- do {
- printf("5. Nhap tiet hoc:");
- gets_s(s[i].TietHoc);
- } while (s[i].TietHoc[1] != '-');
- }
- }
- void SapXep(Lop s[], int n)
- {
- for (int i = 0; i < n-1; i++)
- {
- for (int j = i + 1; j < n; j++)
- {
- if (s[i].MaLop > s[j].MaLop)
- {
- Lop temp = s[i];
- s[i] = s[j];
- s[j] = temp;
- }
- }
- }
- }
- void TimKiemTheoPhong(Lop s[], int n)
- {
- int flag = 0;
- char search[11];
- printf("Nhap ten phong:");
- gets_s(search);
- printf("Ma lop\tTen hoc phan\tPhong hoc\tNgay hoc\tTietHoc\n");
- for (int i = 0; i < n; i++)
- {
- if (strcmp(search, s[i].PhongHoc) == 0)
- XuatLop(s[i]);
- }
- }
- void XuatLop(Lop s)
- {
- printf("%d\t%s\t%s\t%d\t%s\n", s.MaLop, s.TenHocPhan, s.PhongHoc, s.NgayHoc, s.TietHoc);
- }
- void XuatTatCa(Lop s[], int n)
- {
- printf("Ma lop\tTen hoc phan\tPhong hoc\tNgay hoc\tTietHoc\n");
- for (int i = 0; i < n; i++)
- {
- XuatLop(s[i]);
- }
- }
- void KiemTraTrungPhong(Lop s[], int n)
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if ((strcmp(s[i].PhongHoc, s[j].PhongHoc) == 0) && (atoi(s[i].TietHoc) == atoi(s[j].TietHoc)) && (s[i].NgayHoc = s[j].NgayHoc))
- printf("%d", s[i].MaLop); break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement