Target sum triplet

When compiling it’s workin but failed all the test cases not getting the error with the code .
here is my code

#include
#include
using namespace std;
int main(){
int n,target;
cin>>n;
int a[1000];
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>target;
sort(a,a+n);
int left=0;
int right=n-1;
for(int i=0;i<n;i++){
while(left<right){

    if(a[left] + a[right] + a[i]==target){
        cout<<a[i]<<", "<<a[left]<<" and "<<a[right]<<endl;
        left++;
        right--;
    }
    else if(a[left] + a[right] +a[i]> target){
        right--;
    }
    else if(a[left] + a[right] + a[i] < target){
        left++;
    }
}
}
return 0;

}

@coder_girl share your code using cb ide so that i can check

using cb ide means screenshot??

@coder_girl no share your code using the online cb ide here


save and share the link

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.