generated from freudenreichan/info2Praktikum-DobleSpiel
Compare commits
No commits in common. "Moritz" and "main" have entirely different histories.
18
.vscode/c_cpp_properties.json
vendored
18
.vscode/c_cpp_properties.json
vendored
@ -1,18 +0,0 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "windows-gcc-x64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "C:/ProgramData/mingw64/mingw64/bin/gcc.exe",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "${default}",
|
||||
"intelliSenseMode": "windows-gcc-x64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -1,24 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"cwd": "e:/Informatik/Drittes Projekt/DobleSpiel",
|
||||
"program": "e:/Informatik/Drittes Projekt/DobleSpiel/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
59
.vscode/settings.json
vendored
59
.vscode/settings.json
vendored
@ -1,59 +0,0 @@
|
||||
{
|
||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Wshadow",
|
||||
"-Wformat=2",
|
||||
"-Wcast-align",
|
||||
"-Wconversion",
|
||||
"-Wsign-conversion",
|
||||
"-Wnull-dereference"
|
||||
],
|
||||
"C_Cpp_Runner.msvcWarnings": [
|
||||
"/W4",
|
||||
"/permissive-",
|
||||
"/w14242",
|
||||
"/w14287",
|
||||
"/w14296",
|
||||
"/w14311",
|
||||
"/w14826",
|
||||
"/w44062",
|
||||
"/w44242",
|
||||
"/w14905",
|
||||
"/w14906",
|
||||
"/w14263",
|
||||
"/w44265",
|
||||
"/w14928"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
"C_Cpp_Runner.includeSearch": [
|
||||
"*",
|
||||
"**/*"
|
||||
],
|
||||
"C_Cpp_Runner.excludeSearch": [
|
||||
"**/build",
|
||||
"**/build/**",
|
||||
"**/.*",
|
||||
"**/.*/**",
|
||||
"**/.vscode",
|
||||
"**/.vscode/**"
|
||||
],
|
||||
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||
}
|
||||
78
bintree.c
78
bintree.c
@ -8,60 +8,10 @@
|
||||
* `treeSize`: zählt die Knoten im Baum (rekursiv),
|
||||
* `nextTreeData`: Traversierung mit Hilfe des zuvor implementierten Stacks. */
|
||||
|
||||
|
||||
static StackNode *stack = NULL;
|
||||
|
||||
TreeNode* createNode (const void* data, size_t dataSize){
|
||||
|
||||
TreeNode* newNode = (TreeNode*)malloc(sizeof(TreeNode));
|
||||
if (newNode == NULL){
|
||||
// Fehlerbehandlung
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newNode->data = malloc(dataSize);
|
||||
if(newNode->data == NULL){
|
||||
free(newNode); // newNode freigeben
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy (newNode->data, data, dataSize);
|
||||
|
||||
newNode->left = NULL;
|
||||
newNode->right = NULL;
|
||||
return newNode;
|
||||
}
|
||||
|
||||
// Adds a copy of data's pointer destination to the tree using compareFct for ordering. Accepts duplicates
|
||||
// if isDuplicate is NULL, otherwise ignores duplicates and sets isDuplicate to 1 (or to 0 if a new entry is added).
|
||||
TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFctType compareFct, int *isDuplicate)
|
||||
{
|
||||
if (root == NULL)
|
||||
{
|
||||
TreeNode *newNode = createNode(data,dataSize);
|
||||
if (isDuplicate != NULL)
|
||||
*isDuplicate = 0;
|
||||
|
||||
return newNode;
|
||||
}
|
||||
if (compareFct(root->data, data)==0)
|
||||
{
|
||||
if (isDuplicate != NULL) {
|
||||
*isDuplicate=1;
|
||||
return root;
|
||||
}
|
||||
TreeNode *newNode = createNode(data,dataSize);
|
||||
return newNode;
|
||||
}
|
||||
else if (compareFct(root->data, data)>0)
|
||||
{
|
||||
root->left = addToTree(root->left, data, dataSize, compareFct, isDuplicate);
|
||||
}
|
||||
else if (compareFct(root->data, data)<0)
|
||||
{
|
||||
root->right= addToTree(root->right, data, dataSize, compareFct, isDuplicate);
|
||||
}
|
||||
return root;
|
||||
|
||||
}
|
||||
|
||||
@ -70,45 +20,17 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
|
||||
// push the top node and push all its left nodes.
|
||||
void *nextTreeData(TreeNode *root)
|
||||
{
|
||||
if (root != NULL) {
|
||||
clearStack(stack);
|
||||
stack = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Releases all memory resources (including data copies).
|
||||
void clearTree(TreeNode *root)
|
||||
{
|
||||
if (root != NULL) {
|
||||
if (root->left != NULL) {
|
||||
clearTree(root->left);
|
||||
}
|
||||
if (root->right != NULL) {
|
||||
clearTree(root->right);
|
||||
}
|
||||
free(root->data);
|
||||
free(root);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Returns the number of entries in the tree given by root.
|
||||
unsigned int treeSize(const TreeNode *root)
|
||||
{
|
||||
unsigned int size = 0;
|
||||
if (root == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (root->left != NULL)
|
||||
{
|
||||
size += treeSize(root->left);
|
||||
}
|
||||
if (root->right != NULL)
|
||||
{
|
||||
size += treeSize(root->right);
|
||||
}
|
||||
return size+1;
|
||||
|
||||
}
|
||||
Binary file not shown.
@ -1,4 +1 @@
|
||||
Moritz1;9970
|
||||
Moritz;9954
|
||||
Moritz;4986
|
||||
player1;3999
|
||||
|
||||
4
stack.h
4
stack.h
@ -9,10 +9,6 @@ The latest element is taken from the stack. */
|
||||
|
||||
//TODO: passenden Datentyp als struct anlegen
|
||||
|
||||
typedef struct{
|
||||
void *data;
|
||||
}StackNode;
|
||||
|
||||
// Pushes data as pointer onto the stack.
|
||||
StackNode *push(StackNode *stack, void *data);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user