C_Algorithms 2.0.0
Documentation
Loading...
Searching...
No Matches
Functions
main.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "recursiveFib.h"
#include "dynamicFib.h"
#include "patternSearch.h"
#include "stack.h"
#include "queue.h"
#include "doublyLinkedList.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

void FunctionCall ()
 Easy access to all functions of the repository.
 
int main (void)
 This is the main function remove the // befor the function you want to test.
 

Function Documentation

◆ FunctionCall()

void FunctionCall ( )

Easy access to all functions of the repository.

< Creates a new list

< Create a new node

< Create another node

< Create another node

< Print list

< Free the list and all nodes

Definition at line 31 of file main.c.

32{
33 while(1)
34 {
35 char func[2];
36 printf("Which function du you want to test: ");
37 fgets(func, 3, stdin);
38
39 switch (func[0])
40 {
41 case 'a':
42 {
43 // Works fine for smaller numbers ->
44 // Really slow with higher numbers >= 40
45 int num = 10;
46 printf("\nRunning recursive fibonacci function with value of %d...\n", num);
47 printf("RecursiveFib(%d) = ", num);
48 RecursiveFib(num);
49 printf("\n");
50 //exit(0);
51 break;
52 }
53 case 'b':
54 {
55 //Really fast also works with higher numbers
56 int num = 60;
57 printf("\nRunning dynamic fibonacci function with value of %d...\n", num);
58 printf("RecursiveFib(%d) = ", num);
59 DynamicFib(num);
60 printf("\n");
61 break;
62 }
63 case 'c':
64 {
65 //Search for a specific pattern in a Text
66 char text[] = "THIS IS A TEXT TO SEARCH A PATTERN";
67 char pattern[] = "IS A";
68
69 printf("\nRunning pattern search...\n");
70
71 uint32_t x = PatternSearch(text, pattern);
72 if (x == -1)
73 {
74 printf("No matched pattern found!\n");
75 }
76 printf("Pattern found at position %d\n", x);
77
78 printf("\n");
79 break;
80 }
81 case 'd':
82 //Creating your own Stack to Push and pop your data
83 Stack();
84 exit(0);
85 break;
86 case 'e':
87 //Creating your own Queue to Push and pop your data
88 Queue();
89 exit(0);
90 break;
91 case 'f':
92 {
93 printf("\nRunning double linked list...\n");
94
95 List *list = createList();
96 Node *node = createNode();
97
98 node->data_ = 10;
99 appendNodeToEndOfList(list, node, false);
100
101 node = createNode();
102 node->data_ = 20;
103 appendNodeToEndOfList(list, node, false);
104
105 node = createNode();
106 node->data_ = 120;
107 appendNodeToEndOfList(list, node, false);
108
109 printList(list);
110
111 freeList(list);
112
113 printf("\n");
114
115 break;
116 }
117
118 case 'X':
119 case 'x':
120 //Exiting the programm
121 exit(0);
122
123 case '-':
124 switch (func[1])
125 {
126 case 'h':
127 printf("\nEnter the following characters to call the specific functions:\n");
128 printf("(a): Recursive Fibonacci\n");
129 printf("(b): Dynamic Fibonacci\n");
130 printf("(c): Patternsearch\n");
131 printf("(d): Stack\n");
132 printf("(e): Queue\n");
133 printf("(f): Double linked list\n");
134 printf("(X): Exit the programm\n\n");
135 break;
136
137 default:
138 printf("Invalid argument. Use -h for help.\n");
139 break;
140 }
141 break;
142 default:
143 printf("Invalid argument. Use -h for help.\n");
144 break;
145 }
146 fflush(stdin);
147 }
148}
Node * appendNodeToEndOfList(List *list, Node *node, bool check_for_existing_node)
Append a node to the end of a list.
Node * createNode(void)
Allocates memory for a new node and initalizes it.
void printList(List *list)
Print the whole List without trailing .
bool freeList(List *list)
Frees the memory of a list and all nodes in it.
List * createList(void)
Allocates memory for a new list and initalizes it.
void DynamicFib(int number)
Prints the return value of the called function RecFib.
Definition dynamicFib.c:31
uint32_t PatternSearch(char *text, char *pattern)
PatSearch is a Function to search for specific patterns in a text. (Be aware that its case sensitive!...
void Queue()
Definition queue.c:163
void RecursiveFib(int number)
Prints the return value of the called function RecFib.
void Stack()
Definition stack.c:148

References appendNodeToEndOfList(), createList(), createNode(), _Node_::data_, DynamicFib(), freeList(), PatternSearch(), printList(), Queue(), RecursiveFib(), and Stack().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( void )

This is the main function remove the // befor the function you want to test.

Definition at line 19 of file main.c.

20{
21 FunctionCall();
22
23 return 0;
24}
void FunctionCall()
Easy access to all functions of the repository.
Definition main.c:31

References FunctionCall().

Here is the call graph for this function: