Generate matrix of all possible combinations of elements to get a given row sum value
<p>I would like to generate a matrix of all combinations of 3 elements with a fixed element to get a given row sum value <code>n</code>. The result take this format for <code>n=6</code> with fixed column <code>V4</code> value equal to 1:</p>

<pre><code>  V1  V2  V3  V4
   5   0   0   1
   0   5   0   1
   0   0   5   1
   4   1   0   1
   4   0   1   1
   3   2   0   1
   3   0   2   1
   2   3   1   1
   2   1   3   1
   1   2   2   1
   .   .   .   1
   .   .   .   1
   .   .   .   .
   .   .   .   .
</code></pre>

<p>Many thanks in advance!</p>