Advertisement
Dashe

LLS

Jan 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. // LinkedListc.cpp : Defines the entry point for the console application.
  2. //https://www.opentechguides.com/how-to/article/c/141/linkedlist-add-del-print-count.html
  3. //https://www.geeksforgeeks.org/linked-list-set-1-introduction/
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. typedef struct node
  9. {
  10. int data;
  11. struct node * next;
  12. }Node;
  13.  
  14. Node * add(int, Node *);
  15. Node * remove(int , Node *);
  16. Node * display(int, Node *);
  17.  
  18. Node * add(int num, Node *head)
  19. {
  20. Node * newnode;
  21. newnode = (Node *)malloc(sizeof(Node));
  22. newnode->data = num;
  23. newnode->next = head;
  24. head = newnode;
  25. return head;
  26. }
  27.  
  28. Node * remove(int num, Node *head)
  29. {
  30. Node * current = head;
  31. Node * previous;
  32. if (current)
  33.  
  34. }
  35.  
  36.  
  37. {Node * display(int num, Node *head)
  38.  
  39. }
  40.  
  41. int main()
  42. {
  43.  
  44. struct node *head = NULL;
  45. struct node *current = NULL;
  46. struct node *previous = NULL;
  47. int num;
  48. int choice;
  49.  
  50. if (head == NULL)
  51. {
  52. return 1;
  53. }
  54. while (1)
  55. {
  56. printf("1. Add");
  57. printf("2. Remove");
  58. printf("3. Display");
  59. printf("4. Exit");
  60. printf("Choose an option from 1 - 4");
  61. scanf("%d", &choice);
  62.  
  63. switch (choice)
  64. {
  65. case 1:
  66. printf("Enter a value to enter the list");
  67. scanf("%d", &num);
  68. printf("Assign a priority to the value");
  69. printf("The element has been added to the list");
  70. getch();
  71. break;
  72. case 2:
  73. printf("Enter a value to enter the list");
  74. scanf("%d", &num);
  75. printf("The element has been removed from the list");
  76. getch();
  77. break;
  78. case 3:
  79. printf("Here is the list of values and elements");
  80. getch();
  81. break;
  82. case 4:
  83. exit(0);
  84. break;
  85. case 5:
  86. printf("Invalid");
  87. getch();
  88. }
  89. }
  90.  
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement