#include
using namespace std;
int main(){
int a[100];
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
int target;
cin>>target;
for (int step = 0; step < n - 1; ++step)
{
for (int i = 0; i < n - step - 1; ++i)
{
// To sort in descending order, change > to < in this line.
if (a[i] > a[i + 1])
{
int temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
for(int k=j+1;k<n;k++){
if(a[i]+a[j]+a[k]==target){
cout<<a[i]<<", "<<a[j]<<" and "<<a[k];
}
}
}
}
}
code is showing run time error…
what other approach we can use?