#include
#include
using namespace std;
int main()
{
int n, key;
cin >> n;
int a[1000];
for (int x = 0; x < n; x++)
{
cin >> a[x];
}
cin >> key;
std::sort(a, a + n);
for (int i = 0; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
for (int k = j + 1; k < n; k++)
{
if (a[i] + a[j] + a[k] == key)
{
cout << a[i] << ", " << a[j] << " and " << a[k] << endl;
}
}
}
}
return 0;
}
This code works completely well in my IDE but codeblocks says I should use another method other than brute force. I did not understand that.