Guest User

Untitled

a guest
Jan 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct node *head = NULL;
  5. struct node *current = NULL;
  6.  
  7. //structure for the linked list
  8. typedef struct node
  9. {
  10. int data;
  11. struct node * next;
  12. }NODE_T;
  13.  
  14. void insertStates(char data)
  15. {
  16. struct node *connect = (struct node*)malloc(sizeof(struct node));
  17. connect->data = data;
  18. connect->next = head;
  19. head = connect;
  20. }
  21.  
  22. void viewList()
  23. {
  24. struct node *pointer;
  25. printf("n[head] =>");
  26.  
  27. while(pointer != NULL)
  28. {
  29. printf("%c =>", pointer->data);
  30. pointer = pointer->next;
  31. }
  32. printf(" [null]n");
  33. };
  34.  
  35. int main ()
  36. {
  37. int answerStepOne;
  38. char answerStepTwo;
  39. char userContinue;
  40. int i;
  41. int statesTot;
  42.  
  43. printf("***Pick an option.*** n1. Create a new DFA. n2. Load DFA from file.");
  44. scanf("%d", &answerStepOne);
  45. if (answerStepOne == 1)
  46. {
  47. //Create new DFA
  48. printf("Enter single alphabetical states excluding 'z'. (Max states 25)(z to quit)n");
  49. i=1;
  50. while(answerStepTwo != 'z')
  51. {
  52. printf("Enter State[%d]: ",i);
  53. scanf("%s", &answerStepTwo);
  54.  
  55. if(answerStepTwo == 'z')
  56. {
  57. break;
  58. }
  59. else
  60. {
  61. printf("Should have been insertedn");
  62. insertStates(answerStepTwo);
  63. i++;
  64. }
  65. }
  66. }
  67. if(answerStepOne == 2)
  68. {
  69. //Load DFA from file
  70. }
  71.  
  72. viewList();
  73. system ("PAUSE");
  74. return 0;
Add Comment
Please, Sign In to add comment