#include
#include
#include
using namespace std;
// int find(int arr[10],int len,int sum);
int find(int arr[1000], int len, int key){
sort(arr, arr+len);
int i = 0 ;
int j = len -2 ;
int k = len -1 ;
while( i < j && (arr[i]+arr[j]+arr[k])==key){
while((arr[i] + arr[j] + arr[k]) <= key && i < j && j < k ){
if((arr[i] + arr[j] + arr[k]) == key)
cout <<arr[i] << ", " << arr[j] << " and " << arr[k] << endl;
i++;
}
j--;
k--;
while((arr[i] + arr[j] + arr[k]) >= key && i < j && j < k){
if((arr[i] + arr[j] + arr[k]) == key)
cout << arr[i] << ", " << arr[j] << " and "<< arr[k] << endl;
j--;
k--;
}
}
}
int main(){
int n;
cin>>n;
int arr [10000];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int key;
cin>>key;
find(arr, n, key);
}
can anyone tell me the problem