Test case given to me is working fine but other cases are not working.
Wrong answer is comming
#include #include bool comp(int a,int b){ return a<b; } using namespace std; void three(int a[],int asli,int j,int n,int i=0){ while(i<j){ if((a[i]+a[j])==n){ cout<<a[i]<<", “<<a[j]<<” and "<<asli<<endl; i++; j–; } else if((a[i]+a[j])>n){ j–; } else if((a[i]+a[j])<n){ i++; } } } int main() { int n; int t; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } cin>>t; sort(a,a+n,comp); for(int i=n-1;i>=0;i–){ three(a,a[i],i-1,t-a[i]); } return 0;
Go to ide.codingblocks.com
Paste your code there
Save it there
It will generate a special url in your search bar
Share that url with me
Have debugged your code here
also have added comments for better understanding. If this solves your query, then mark it as resolved.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.