fix errors 1
This commit is contained in:
parent
c1d0fc9d87
commit
79c639faa5
@ -48,7 +48,7 @@ int main(void) {
|
||||
int len_number = strlen(number);
|
||||
for (int j = 0; j < len_number; j++) { // loop over chars in the phone number
|
||||
int index = number[j] - '0'; // Go to the node we're testing
|
||||
if (pointer->children[index == NULL]) {
|
||||
if (pointer->children[index] == NULL) {
|
||||
pointer->children[index] = newNode();
|
||||
};
|
||||
pointer = pointer->children[index];
|
||||
@ -69,7 +69,7 @@ int main(void) {
|
||||
printf("FOUND PREFIX IN NUMBER\n");
|
||||
printf("%s and %s", number, number);
|
||||
while (pointer->isEnd != true) { // follow the first path you can find
|
||||
for (int k = 0; k < 10; k++) {
|
||||
for (int k = 0; k < 10; k++) {
|
||||
if( pointer->children[k] != NULL) {
|
||||
pointer = pointer->children[k];
|
||||
printf("%c", k + '0'); // Print the path as we go
|
||||
@ -83,7 +83,7 @@ int main(void) {
|
||||
};
|
||||
pointer->isEnd = true;
|
||||
};
|
||||
else if (pointer->isEnd == true) { // if we've already seen a shorter number with this prefix
|
||||
if (pointer->isEnd == true) { // if we've already seen a shorter number with this prefix
|
||||
printf("Found prefix!\n");
|
||||
for (int k = 0; k < j; k++) {
|
||||
printf("%c", number[k]);
|
||||
|
Loading…
Reference in New Issue
Block a user