|
@@ -27,14 +27,14 @@ int main()
|
|
|
nums >> b[i];
|
|
|
}
|
|
|
|
|
|
- int clen = (n * (n - 1)) / 2; // total possible sums in an array of length 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;
|
|
|
|
|
|
// Store within c the possible sums inside b
|
|
|
for (int i = 0; i < n; ++i)
|
|
|
{
|
|
|
- for (int j = (i + 1); j < n; ++j, ++tempcount)
|
|
|
+ for (int j = i; j < n; ++j, ++tempcount)
|
|
|
{
|
|
|
c[tempcount] = b[i] + b[j];
|
|
|
}
|