there is some problem in the output⦠sir pls tell whats the problem with the codeā¦
#include
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,i,j,k,target,arr[1000];
cin>>n;
//reading array elements
for(i=0;i<n;i++){
cin>>arr[i];
}
cin>>target;
for(i=0;i<n-2;i++){
for(j=i+1;j<n-1;j++){
for(k=j+1;k<n;k++){
if(arr[i]+arr[j]+arr[k]==target){
if (arr[i] > arr[j])
swap(arr[i], arr[j]);
if (arr[i] > arr[k])
swap(arr[i], arr[k]);
if (arr[j] > arr[k])
swap(arr[j], arr[k]);
cout<<arr[i]<<","<<" "<<arr[j]<<" "<<"and"<<" "<<arr[k]<<endl;
}
}
}
}
return 0;
}