Skip to content

Instantly share code, notes, and snippets.

@vzarytovskii
Created April 10, 2019 22:18
Show Gist options
  • Save vzarytovskii/6a10c1aad35d9ae77c71cf97da47dea1 to your computer and use it in GitHub Desktop.
Save vzarytovskii/6a10c1aad35d9ae77c71cf97da47dea1 to your computer and use it in GitHub Desktop.
#define MAX 100000
void printPairs(int arr[], int arr_size, int sum)
{
int i, temp;
bool s[MAX] = {0};
for (i = 0; i < arr_size; i++)
{
temp = sum - arr[i];
if (temp >= 0 && s[temp] == 1)
printf("sum=%d is (%d, %d) n", sum, arr[i], temp);
s[arr[i]] = 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment