Getting wrong answer in target sum pair

i have submitted the code and it shows wrong ans in the 1st test case even tho its showing the correct ans when i run the code in the coding blocks ide as well as xcode ide

@mehtaprakhar16 hey prakhr can you please share your implementation.

#include
#include
#include
#include
using namespace std;
int main(int argc, const char * argv[]) {
int n,i,j,t;
cin>>n;
int a[n];
for(i=0;i<n;i++){

        cin>>a[i];
    for(j=0;j<i;j++){
        if(a[i]==a[j]) a[i]=100;
    }
}
cin>>t;
for(i=0;i<n;i++){
  
        for(j=0;j<n;j++){
              if(a[i]+a[j]==t){
              cout<<(a[i]>a[j]?a[j]:a[i])<<" and "<<(a[i]>a[j]?a[i]:a[j]);
              a[j]=t+1;
              cout<<endl;
        }
        else continue;
    }
    
  
}

return 0;

}

@mehtaprakhar16 hey prakr you have to follow the simple trick solution is that sort the element of array then apply two loop which help you to solve this problem in o(n*n)