# Copy of Snippet "New Snippet"

SCry

#include <iostream>
#include <string>
#include <map>
#include <iterator>
#include <sstream>
using namespace std;

string ArrayCouples(int arr, int size)
{
map <int, int> table;

// traverse our array
for (int x = 0; x < size - 1; x += 2)
{
bool found = false;

// section to analyze our hash table
for (auto y = table.begin(); y != table.end(); y++)
{
if ((y->first == arr && y->second == arr[x + 1]) || (y->first == arr[x + 1] && y->second == arr))
{

table.erase(y->first);
found = true;
break;
}
}

if (!found)
{
table[arr] = arr[x + 1];
}
}
if (table.empty())
{
return "yes";
}
ostringstream convert;
for (auto x = table.begin(); x != table.end(); x)
{
convert << x->first << "," << x->second;
x++;

if (x != table.end())
{
convert << ",";
}
}

return convert.str();
}

int main()
{
int A = { 4, 5, 1, 4, 5, 4, 4, 1 };
int B = { 6, 2, 2, 6, 5, 14, 14, 1 };
int C = { 2, 1, 1, 2, 3, 3 };
int D = { 5, 4, 6, 7, 7, 6, 4, 5 };

cout << ArrayCouples(A, sizeof(A)/sizeof(A[0])) << endl; // yes
cout << ArrayCouples(B, sizeof(B) / sizeof(B[0])) << endl; // 5,14,14,1
cout << ArrayCouples(C, sizeof(C) / sizeof(C[0])) << endl; // 3,3
cout << ArrayCouples(D, sizeof(D) / sizeof(D[0])) << endl; // yes
return 0;

}