generated from freudenreichan/info2Praktikum-DobleSpiel
fixed the programm except for the highscores being displayed in exactly the wrong order
This commit is contained in:
parent
fdfa3c5769
commit
027a8eaeb7
18
bintree.c
18
bintree.c
@ -22,7 +22,7 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
|
||||
newNode->data = malloc(dataSize);
|
||||
newNode->left = NULL;
|
||||
newNode->right = NULL;
|
||||
strcpy(newNode->data, data);
|
||||
memcpy(newNode->data, data, dataSize);
|
||||
if(isDuplicate)
|
||||
*isDuplicate = 0;
|
||||
return newNode;
|
||||
@ -52,19 +52,16 @@ 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)
|
||||
{
|
||||
printf("nextTreeData wurde gecallt!\n");
|
||||
if(root)
|
||||
{
|
||||
stackRoot = addTreeToStack(stackRoot, root);
|
||||
printf("Baum wurde geladen!\n");
|
||||
}
|
||||
printf("\n\nstackRoot ist: %x\n\n", stackRoot);
|
||||
StackNode *stackPuffer = pop(stackRoot);
|
||||
if(!stackPuffer)
|
||||
printf("Something went horriffically wrong! There is no Data!");
|
||||
void *buffer = (stackPuffer->stackData);
|
||||
printf("neuer Eintrag wurde geholt: %x\n", buffer);
|
||||
return buffer;
|
||||
void *stackBuffer = top(stackRoot);
|
||||
stackRoot = pop(stackRoot);
|
||||
//void *buffer = (stackBuffer->stackData);
|
||||
//printf("neuer Eintrag wurde geholt: %x\n", buffer);
|
||||
//return buffer;
|
||||
return stackBuffer;
|
||||
}
|
||||
// Adds all Treenode-Datas of a root into a stack ordered from left to right
|
||||
StackNode *addTreeToStack(StackNode *start, TreeNode *root)
|
||||
@ -74,7 +71,6 @@ StackNode *addTreeToStack(StackNode *start, TreeNode *root)
|
||||
start = addTreeToStack(start, root->left);
|
||||
}
|
||||
start = push(start, root->data);
|
||||
printf("\na new Dataset has been added! new stackRoot: %x", start);
|
||||
if(root->right)
|
||||
{
|
||||
start = addTreeToStack(start, root->right);
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
HeldDerSteine;69
|
||||
Gunter11;121
|
||||
MaxiMustermann;316
|
||||
MillaMusterfrau;420
|
||||
testspieler68;2996
|
||||
testspieler69;2997
|
||||
testspieler67;2997
|
||||
testspieler1;2997
|
||||
testspieler68;4991
|
||||
|
||||
1
main.c
1
main.c
@ -84,6 +84,5 @@ int main(int argc, char *argv[])
|
||||
|
||||
exitCode = EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
6
stack.c
6
stack.c
@ -34,14 +34,12 @@ StackNode *push(StackNode *stack, void *data)
|
||||
// freed by caller.)
|
||||
StackNode *pop(StackNode *stack)
|
||||
{
|
||||
printf("A stack is being popped");
|
||||
if(stack) {
|
||||
StackNode* temp = stack;
|
||||
stack = stack->below;
|
||||
temp->stackData = NULL;
|
||||
//free(temp);
|
||||
//temp = NULL;
|
||||
printf("Stack returns stack at: %x\n", stack);
|
||||
free(temp);
|
||||
temp = NULL;
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user