diff --git a/Commissions/flis/IMT/Case3/case3.c b/Commissions/flis/IMT/Case3/case3.c index 7445ed9..4b77b23 100644 --- a/Commissions/flis/IMT/Case3/case3.c +++ b/Commissions/flis/IMT/Case3/case3.c @@ -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; }; }; }; -} \ No newline at end of file +} diff --git a/Commissions/flis/IMT/Case3/shell.nix b/Commissions/flis/IMT/Case3/shell.nix index d364c29..ca0b8c5 100644 --- a/Commissions/flis/IMT/Case3/shell.nix +++ b/Commissions/flis/IMT/Case3/shell.nix @@ -1,5 +1,5 @@ with import {}; stdenv.mkDerivation { name = "c-shell"; - buildInputs = [ gcc gnumake ]; + buildInputs = [ gcc gnumake gdb ]; }