1. Stephen Tanner
  2. subc

Commits

Stephen Tanner  committed 0eb8cd9

Comenting updates

  • Participants
  • Parent commits 1f788cb
  • Branches default

Comments (0)

Files changed (9)

File Debug/src/array.o

Binary file modified.

File Debug/src/bitwise.o

Binary file modified.

File Debug/src/main.o

Binary file modified.

File Debug/src/recursive.o

Binary file modified.

File Debug/subc

Binary file modified.

File src/bitwise.c

View file
 
 
 bool bitwise_find_substring (int first_int, int second_int) {
-
+    //main bitwise function.
+    //Reuturns true if it finds a match
 
     int m_index = 0;
     bool found = false;

File src/main.c

View file
     printf("What is the second integer?: ");
     scanf("%d", &second_int);
     printf("\n");
+
+    //Check the input
     if (first_int < 0 || second_int < 0) {
         printf("No negative numbers please... \n -_- \n");
         return 1;
     }
+
+    //get to work
     bool bitwise = bitwise_find_substring(first_int, second_int);
     if (!bitwise) {
         printf("Bitwise: No Match Found\n\n");
             printf("Recursive: No Match Found\n\n");
     }
 
-
-
     return 0;
 }
 

File src/recursive.c

View file
 bool find_subs(bool found, int *match_count, int shifts_left, int first_int, int second_int, int mask, int firstbit);
 
 bool recursive_find_substring (int first_int, int second_int) {
-
+        //The main recursive function.
+        //Will return true if it finds and prints a match
 
         int match_count = 0;
         bool found = false;
         int i;
 
 
+        //build a mask
         int length = 0;
         int mask = 0;
         for (i = SIZE - 1; i >= 0; i--) {
                 break;
             }
         }
+        //handel 0 case
         if (!firstbit) {
             firstbit = 1;
         }
 
         int shifts_left = firstbit - length;
+        //Handel second int too large
         if (shifts_left < 0 ) {
             return false;
         }
 
+        //run recursive helper function
         bool sub_found = find_subs(found, &match_count, shifts_left, first_int, second_int, mask, firstbit);
 
         if (sub_found) {
         }
         *match_count = *match_count + 1;
     }
+    //Regardless of finding a match, shift and recurse
     mask = (mask << 1);
     second_int = (second_int << 1);
     shifts_left--;

File src/substring.h

View file
 
 #ifndef SUBSTRING_H_
 #define SUBSTRING_H_
+
+//Include these in all files
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+//Declerations of war! errr I mean functions
 bool bitwise_find_substring (int first_int, int second_int);
 bool array_find_substring (int first_int, int second_int);
 bool recursive_find_substring (int first_int, int second_int);