fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. struct Student {
  4. int id;
  5. char *name;
  6. struct Student* next;
  7. };
  8. void append(struct Student *start, int id, char *n){
  9. struct Student *temp;
  10. temp = (struct Student *)malloc(sizeof(struct Student));
  11. printf("Exec");
  12. temp->next = NULL;
  13. temp->id = id;
  14. temp->name = n;
  15. if(start == NULL)
  16. {
  17. start = temp;
  18. return;
  19. }
  20. while(start->next != NULL)
  21. {
  22. start = start -> next;
  23. }
  24. start->next = temp;
  25. }
  26. void display(struct Student *start,int find){
  27. if(start->next == NULL && start->id!=find)
  28. {
  29. printf("-1");
  30. return;
  31. }
  32. while(start->next != NULL && start->id != find)
  33. {
  34. start = start->next;
  35. }
  36. if(start->id == find){
  37. start = start->next;
  38. while(start->next != NULL)
  39. {
  40. printf("%s\n",start->name);
  41. }
  42. }
  43. }
  44. int main() {
  45. int N;
  46. scanf("%d",&N);
  47. int id;
  48. char name[100];
  49. struct Student *root;
  50. while(N--) {
  51. scanf("%d %s",&id,name);
  52. append(&root,id,name);
  53. }
  54. int SIN;
  55. scanf("%d",&SIN);
  56. display(root,SIN);
  57. return 0;
  58. }
Runtime error #stdin #stdout 0s 10320KB
stdin
3
12 poo
13 ret
14 hem
13
stdout
Standard output is empty