Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. void InPut(Lop s[], int &n)
  2. {
  3. do {
  4. printf("Nhap so luon can them: ");
  5. scanf_s("%d", &n);
  6. } while (n < 1);
  7. for (int i = 0; i < n; i++)
  8. {
  9. printf("1. Nhap ma lop");
  10. scanf_s("%d", &s[i].MaLop);
  11. rewind(stdin);
  12. printf("2. Nhap ten hoc phan");
  13. gets_s(s[i].TenHocPhan);
  14. printf("3. Nhap phong hoc");
  15. gets_s(s[i].PhongHoc);
  16. do {
  17. printf("4. Nhap ngay hoc trong tuan");
  18. scanf_s("%d", &s[i].NgayHoc);
  19. } while (s[i].NgayHoc < 2 && s[i].NgayHoc > 7);
  20. rewind(stdin);
  21. do {
  22. printf("5. Nhap tiet hoc:");
  23. gets_s(s[i].TietHoc);
  24. } while (s[i].TietHoc[1] != '-');
  25. }
  26. }
  27.  
  28. void SapXep(Lop s[], int n)
  29. {
  30. for (int i = 0; i < n-1; i++)
  31. {
  32. for (int j = i + 1; j < n; j++)
  33. {
  34. if (s[i].MaLop > s[j].MaLop)
  35. {
  36. Lop temp = s[i];
  37. s[i] = s[j];
  38. s[j] = temp;
  39. }
  40. }
  41. }
  42. }
  43. void TimKiemTheoPhong(Lop s[], int n)
  44. {
  45. int flag = 0;
  46. char search[11];
  47. printf("Nhap ten phong:");
  48. gets_s(search);
  49. printf("Ma lop\tTen hoc phan\tPhong hoc\tNgay hoc\tTietHoc\n");
  50. for (int i = 0; i < n; i++)
  51. {
  52. if (strcmp(search, s[i].PhongHoc) == 0)
  53. XuatLop(s[i]);
  54. }
  55. }
  56. void XuatLop(Lop s)
  57. {
  58.  
  59. printf("%d\t%s\t%s\t%d\t%s\n", s.MaLop, s.TenHocPhan, s.PhongHoc, s.NgayHoc, s.TietHoc);
  60. }
  61. void XuatTatCa(Lop s[], int n)
  62. {
  63. printf("Ma lop\tTen hoc phan\tPhong hoc\tNgay hoc\tTietHoc\n");
  64. for (int i = 0; i < n; i++)
  65. {
  66. XuatLop(s[i]);
  67. }
  68. }
  69. void KiemTraTrungPhong(Lop s[], int n)
  70. {
  71. for (int i = 0; i < n; i++)
  72. {
  73. for (int j = 0; j < n; j++)
  74. {
  75. if ((strcmp(s[i].PhongHoc, s[j].PhongHoc) == 0) && (atoi(s[i].TietHoc) == atoi(s[j].TietHoc)) && (s[i].NgayHoc = s[j].NgayHoc))
  76. printf("%d", s[i].MaLop); break;
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement