Last active
November 19, 2021 03:42
-
-
Save shrujandev/a97a286f168bb90d9ff961859254ffd0 to your computer and use it in GitHub Desktop.
Revisions
-
shrujandev revised this gist
Nov 19, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ void findPath(Head * ptr, int endI, int endJ, FILE * output) { Stack * stack; //struct containg a node and pointer to the same type int condition = 0; stack = (Stack * ) malloc(sizeof(Stack)); //Mallocing the stack stack -> head = NULL; Node * move; //This pointer is the one that moves and finds path move = ptr -> head; pushElement(stack, move); while (condition == 0) { -
shrujandev created this gist
Nov 19, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ void findPath(Head * ptr, int endI, int endJ, FILE * output) { Stack * stack; int condition = 0; stack = (Stack * ) malloc(sizeof(Stack)); stack -> head = NULL; Node * move; move = ptr -> head; pushElement(stack, move); while (condition == 0) { if (move -> i < endI && move -> j < endJ) { if (move -> right -> data == 0) { move = move -> right; pushElement(stack, move); } else if (move -> down -> data == 0) { move = move -> down; pushElement(stack, move); } else if (move -> down -> data != 0 && move -> right -> data != 0) { move -> data = 1; move = popElement(stack); } } else if (move -> i == endI && move -> j != endJ) { if (move -> right -> data == 0) { move = move -> right; pushElement(stack, move); } else if (move -> down -> data != 0 && move -> right -> data != 0) { move -> data = 1; move = popElement(stack); } } else if (move -> i != endI && move -> j == endJ) { if (move -> down -> data == 0) { move = move -> down; pushElement(stack, move); } else if (move -> down -> data != 0 && move -> right -> data != 0) { move -> data = 1; move = popElement(stack); } } else { condition = 1; } }