I think it works now

This commit is contained in:
Daniel Olsen 2020-11-25 09:45:43 +01:00
parent 79c639faa5
commit a5aa29f1ac
2 changed files with 8 additions and 11 deletions

View File

@ -37,10 +37,8 @@ int numbers[] = {113, 11354, 77777, 255044};
int main(void) {
struct Node* root = newNode();
printf("%p\n", root);
int n_numbers = sizeof(numbers)/sizeof(int);
for (int i = 0; i < n_numbers; i++) { // Go through all the phone numbers in the global list
struct Node* pointer = root; // Create a pointer that points to whatever part of the trie we're working on
char number[8 + 1]; // A number has 8 + \0 chars
@ -66,7 +64,6 @@ int main(void) {
};
};
if (continues == true) {
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++) {
@ -82,14 +79,14 @@ int main(void) {
return 0; // return true or success or whatever
};
pointer->isEnd = true;
};
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++) {
}
else if (pointer->isEnd == true) { // if we've already seen a shorter number with this prefix
for (int k = 0; k <= j; k++) {
printf("%c", number[k]);
}
printf("\n");
printf(" and %i\n", numbers[i]);
return 0;
};
};
};
}
}

View File

@ -1,5 +1,5 @@
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "c-shell";
buildInputs = [ gcc gnumake ];
buildInputs = [ gcc gnumake gdb ];
}