Triplet Sum print the integer

#include
#include
using namespace std;

void tripletSum(int a[], int n, int target) {

for(int i=0; i<n; i++) {
	for(int j=i+1; j<n; j++) {
		for(int k=j+1; k<n; k++) {
			// Sum is equal == target
			if(a[i] + a[j] + a[k] == target) { 
				int temp[] = {a[i],a[j],a[k]};
				sort(temp, temp+3);
				for(int g=0; g<3; g++){
					cout << temp[g] << ","; 
				}
				cout << endl;
				break;
			}
		}
	}
}

}

int main(int argc, char const *argv[])
{
int N,target;
int a[1000];
cin >> N;
for(int i=0; i<N; i++){
cin >> a[i];
}
cin >> target;
tripletSum(a,N,target);
return 0;
}

output
9
5 7 9 1 2 4 6 8 3
10
1,4,5,
2,3,5,
1,2,7,
1,3,6,

the output is printed in the above should i need to store the above output in the multidimensional arrays and then sort temp