Guest User

Untitled

a guest
May 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. void print_students(slist *head){
  2. clist * head_c;
  3.  
  4. if(!head) {
  5. printf("STUDENT LIST: EMPTY!\n");
  6. return;
  7. }
  8. else{
  9. printf("STUDENT LIST:\n");
  10.  
  11. while(head){
  12. printf("%d:%s\n",head->info->id,head->info->name);
  13. head_c=head->info->courses;
  14. if(!head_c)
  15. printf("student is not registered for courses.\n");
  16. else{
  17. printf("courses: ");
  18. while(head_c){
  19.  
  20. printf("%d-%s",head_c->info->number,head_c->info->title);
  21. head_c=head_c->next;
  22. (!head_c?printf("\n"):printf(", "));
  23. }
  24. }
  25. head=head->next;
  26. }
  27. }
  28. }
  29. void print_courses(clist *head){
  30. slist * head_s;
  31.  
  32. if(!head) {
  33. printf("COURSE LIST: EMPTY!\n");
  34. return;
  35. }
  36. else{
  37. printf("STUDENT LIST:\n");
  38. while(head){
  39. printf("%d:%s\n",head->info->number,head->info->title);
  40. head_s=head->info->students;
  41. if(!head_s)
  42. printf("course has no students.\n");
  43. else{
  44. printf("courses: ");
  45. while(head_s!=NULL){
  46.  
  47. printf("%d-%s",head_s->info->id,head_s->info->name);
  48. head_s=head_s->next;
  49. (!head_s?printf("\n"):printf(", "));
  50. }
  51. }
  52. head=head->next;
  53. }
  54. }
  55. }
Add Comment
Please, Sign In to add comment