Test case 4 not passed( arrays -target sum pairs

#include
using namespace std;

void sumequaltarget(int a[],int target, int n){

for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		if((a[i]+a[j])==target){
			if(a[i]<a[j]){
			cout<<a[i]<<" and "<<a[j]<<endl;
			a[i]=-100;
			}else{
				cout<<a[j]<<" and "<<a[i]<<endl;
				a[i]=-100;
			}
		}
	}
}

}

int main() {

long long int n;
cin>>n;

int a[n];

for(int i=0;i<n;i++){

	cin>>a[i];

}


int target;

cin>>target;

sumequaltarget(a,target,n);

return 0;

}

@myself.yash.srivastav
Your code fails if there are multiple pairs with same values.
Input :
3
2 3 3
5

Expected Output :
2 and 3
2 and 3

Your Output :
2 and 3

resolved that issue that u have mentioned but still test case 4 not passing …here is my code

#include using namespace std; void sumequaltarget(int a[],int target, int n){ int b[n]; for(int i=0;i<n;i++){ b[i]=a[i]; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if((a[i]+b[j])==target){ if(a[i]<=b[j]){ cout<<a[i]<<" and “<<b[j]<<endl; b[i]=-100; }else{ cout<<b[j]<<” and "<<a[i]<<endl; b[i]=-100; } } } } } int main() { long long int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } int target; cin>>target; sumequaltarget(a,target,n); return 0; }

@myself.yash.srivastav
Your code considers pairs of numbers with themselves as well.
Input :
3
2 3 4
6

Expected Output :
2 and 4

Your Output :
2 and 4
3 and 3