ARRAYS-TARGET SUM TRIPLETS--sample case passes but test cases give wrong answer

link to ques: https://hack.codingblocks.com/contests/c/457/215

#include
#include <string.h>
using namespace std;

int main()
{
int n,c=0;
cin>>n;
long long int a[n],target;

for(int i=0;i<n;i++)
	cin>>a[i];

cin>>target;

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

return 0;

}

Hello Shagun ! , you are supposed to print output in sorted order .Others part of ur code seems fine.
If you still feel any difficulty then do ask me !

how do we print the output of this code in sorted order

While printing print first whoever is smallest and so on.