Find Triangle Triplets from a list of given numbers
First thing to comment on after copying and pasting into my IDE, the following line gives a warning:


int size = vec_input.size();

  
  Implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'int'


Apparently, the size() method of Vector returns an unsigned long, and we should use this type for our size, rather than int.

unsigned long size = input.size();




Functions that return void but accept (and modify) an argument passed by reference are always a warning sign for me.  Here, I don't think there's a particularly good reason to do so.

Here, I can't see any good reason to be doing so.  We create and return a vector within the function, and only accept the input argument.



Another problem I see: the result we're giving the caller is a vector of vectors, and the inner vectors are supposed to always have exactly 3 values in it.  Why don't we create a struct to represent the triplets?

struct Triplet {
    int a;
    int b;
    int c;
}


Now we can return a vector of these.



I would also abstract that complex conditional into its own function.

bool isTriplet(int a, int b, int c) {
    return ((a + b) &gt; c) &amp;&amp; ((a + c) &gt; b) &amp;&amp; ((b + c) &gt; a);
}




Now, putting all that together, without changing the algorithm or any of the logic, the code looks like this:

#include&lt;vector&gt;
#include&lt;iostream&gt;

struct Triplet {
    int a;
    int b;
    int c;
};

bool isTriplet(int a, int b, int c) {
    return ((a + b) &gt; c) &amp;&amp; ((a + c) &gt; b) &amp;&amp; ((b + c) &gt; a);
}

std::vector&lt;Triplet&gt; findTriangleTriplets(std::vector&lt;int&gt; input) {
    std::vector&lt;Triplet&gt; triplets;
    unsigned long size = input.size();

    for(int i=0;i&lt;size;++i) {
        for(int j=i+1;j&lt;size;++j) {
            for(int k=0;k&lt;size;++k) {
                int a = input.at(i);
                int b = input.at(j);
                int c = input.at(k);

                if(isTriplet(a, b, c)) {
                    Triplet t = Triplet{a,b,c};
                    triplets.emplace_back(t);
                }
            }
        }
    }

    return triplets;
}

int main()
{
    std::vector&lt;Triplet&gt; triplets;
    std::vector&lt;int&gt; vec_input { 1, 2, 3, 4, 5, 6 };

    triplets = findTriangleTriplets(vec_input);
    for ( auto &amp;x : triplets)
    {
        std::cout&lt;&lt;x.a&lt;&lt;" "&lt;&lt;x.b&lt;&lt;" "&lt;&lt;x.c&lt;&lt;"\n";
    }

    return 0;
}