i am solving array-target sum pairs,using hashing,pls find why i am not getting ac
my code starts here
#include<bits/stdc++.h>
using namespace std;
void pairs(int *a,int n,int t)
{
int i,temp;
bool map[1000]={0};
for(i=0;i<n;i++)
{
temp=t-a[i];
if(temp>0 && map[temp]==1)
cout<<temp<<" and "<<a[i]<<endl;
map[a[i]]=1;
}
}
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int t;
cin>>t;
pairs(a,n,t);
return 0;
}
Code not submitted after correct outout too
i have commented mistake check this
https://ide.codingblocks.com/s/72025
And save ur code to https://ide.codingblocks.com and then paste the link here