N2 doesnt work can u help please

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n]={0};

for(int i=0;i<n;i++)
{
  cin>>a[i];
  cin.get();
}
int k=0;
cin>>k;
for(int i=0;i<n-1;i++)
{
	for(int j=i+1;j<n;j++)
	{
		if((a[i]+a[j])==k)
		{
			cout<<a[i]<<" "<<"and"<<" "<<a[j]<<endl;
		}
	}
}
return 0;

}

this is n2 approach but some test cses are not passed