Browse Source

modified i1 = i2 logic for the checking of the non summed array, also changed output to conform with the question requirements

tarfeef101 7 years ago
parent
commit
7e7d0f4d93
2 changed files with 5 additions and 5 deletions
  1. BIN
      q5/q5_test
  2. 5 5
      q5/q5a.cpp

BIN
q5/q5_test


+ 5 - 5
q5/q5a.cpp

@@ -46,18 +46,18 @@ int main()
     // for reach sum in a, see if it is in c. n squared checks of log (n squared), or n squared log n
     for (int i = 0; i < clen; ++i)
     {
-        for (int j = (i + 1); j < n; ++j)
+        for (int j = i; j < n; ++j)
         {
             if (binary_search(c, (c + clen), (a[i] + a[j])))
             {
                 free(a); free (b); free(c);
-		cout << 1 << endl;
-                return true;
+		cout << "TRUE" << endl;
+                return 0;
             }
         }
     }
     
     free(a); free(b); free(c);
-    cout << 0 << endl;
-    return false;
+    cout << "FALSE" << endl;
+    return 0;
 }