fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define NUM_SUBJECTS 5
  6.  
  7. enum Subject {
  8. MATH, SCIENCE, ENGLISH, HISTORY, PROGRAMMING
  9. };
  10.  
  11. struct Student {
  12. char name[50];
  13. enum Subject subjects[NUM_SUBJECTS];
  14. float grades[NUM_SUBJECTS];
  15. struct Student *next;
  16. };
  17.  
  18. // ... ฟังก์ชันอื่นๆ (createNode, addNode, printList, freeList)
  19.  
  20. int main() {
  21. // ... โค้ดเดิม
  22.  
  23. // เช่น เพิ่มฟังก์ชันค้นหาข้อมูลนักเรียนตามชื่อ
  24. struct Student* findStudent(struct Student* head, const char* name) {
  25. struct Student* current = head;
  26. while (current != NULL) {
  27. if (strcmp(current->name, name) == 0) {
  28. return current;
  29. }
  30. current = current->next;
  31. }
  32. return NULL;
  33. }
  34.  
  35. // ...
  36. }
  37.  
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
Standard output is empty