Arrays-Target Sum Pairs not passing last testcases

here’s my code .It’s not passing last testcase please help!!

#include
#include
#include
#include
#include
#include
using namespace std;

int main() {
int n,target;
cin>>n;
int arr[n];

for(int i=0;i<n;i++)
{
cin>>arr[i];
}
cin>>target;

int *it;
for(int i=0;i<=target/2;i++)
{

 if( target-i==*(find(arr,arr+n,target-i)) && i==*(find(arr,arr+n,i)))
   {  
        cout<<i<<" and "<<target-i<<endl;
    }

}

return 0;
}

Heyy ! Actually the problem is , your code is using each variable twice for printing one pair ,i.e. If the input is
5
1 2 3 4 5
6
Then , for these inputs you are printing (3,3) which is not supposed to be counted .
You just need to check if i == target-i and frequency(i) <2 , if it is then just skip for the current i .
I have modified ur code
https://ide.codingblocks.com/s/46248

Well , you can do this using unordered_map also, take a look on the below code .
https://ide.codingblocks.com/s/46252