|
@@ -5,38 +5,6 @@
|
|
|
#include <sstream>
|
|
|
using namespace std;
|
|
|
|
|
|
-/*int n;
|
|
|
-int twon = 2 * n;
|
|
|
-int * a;
|
|
|
-int * b;
|
|
|
-int * sums = malloc(2 * sizeof(b));
|
|
|
-int pos = 0;
|
|
|
-
|
|
|
-for (int i = 0; i < twon; i++)
|
|
|
-
|
|
|
-{
|
|
|
- for (int j = (i + 1); j < twon; j++, pos++)
|
|
|
-
|
|
|
- {
|
|
|
- sums[pos] = b[i] + b[j];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-sort c;
|
|
|
-
|
|
|
-for (int i = 0; i < twon; i++)
|
|
|
-
|
|
|
-{
|
|
|
- for (int j = (i + 1); j < twon; j++, pos++)
|
|
|
-
|
|
|
- {
|
|
|
- if sums.search(a[i] + a[j]) return true;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-return false;
|
|
|
-
|
|
|
-================*/
|
|
|
int main()
|
|
|
{
|
|
|
string en;
|
|
@@ -54,32 +22,11 @@ int main()
|
|
|
string input;
|
|
|
getline(cin, input);
|
|
|
stringstream nums(input);
|
|
|
- //input >> nums;
|
|
|
|
|
|
nums >> a[i];
|
|
|
- cout << "This is a[" << i << "] " << a[i] << endl;
|
|
|
nums >> b[i];
|
|
|
- cout << "This is b[" << i << "] " << b[i] << endl;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- int clen = 2 * n;
|
|
|
- int * C = malloc(clen * sizeof(int)); // to hold the list of possible sums
|
|
|
- int tempcount = 0;
|
|
|
-
|
|
|
- for (int i = 0; i < n; i++)
|
|
|
-
|
|
|
- {
|
|
|
- for (int j = (i + 1); j < n; ++j, ++tempcount)
|
|
|
-
|
|
|
- {
|
|
|
- C[tempcount] = (B[i] + B[j]);
|
|
|
- C[clen - tempcount - 1] = (A[i] + A[j]);
|
|
|
- }
|
|
|
- } // n squared
|
|
|
-
|
|
|
- sort(C, C + clen); // n^2 log n squared == n^2 log n */
|
|
|
-
|
|
|
int clen = (n * (n - 1)) / 2; // total possible sums in an array of length n
|
|
|
int * c = (int *) malloc(clen * sizeof(int));
|
|
|
int tempcount = 0;
|