<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Alle Kombinationen mit variabler Anzahl von Items]]></title><description><![CDATA[<p>Hallo ihr,</p>
<p>ich muss eine Funktion bauen, die mir alle Kombinationen von einer variablen Anzahl von Items ausspuckt. Jedes Item hat die gleiche Anzahl an verschiedenen Werten.<br />
Also letztendlich bei z.B. 3 Items und 10 Werten<br />
1 1 1<br />
1 1 2<br />
. . .<br />
5 6 9<br />
. . .<br />
10 10 10</p>
<p>und das ganze variabel für n Items und m Werten</p>
<p>ich vermute mal ich muss das rekursiv programmieren steh aber aufm Schlauch wie das gehen kann.</p>
<p>Könnt ihr mir da nen Anreiz geben?</p>
<p>Viele Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/303539/alle-kombinationen-mit-variabler-anzahl-von-items</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 11:09:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/303539.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 May 2012 14:02:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Wed, 16 May 2012 14:02:43 GMT]]></title><description><![CDATA[<p>Hallo ihr,</p>
<p>ich muss eine Funktion bauen, die mir alle Kombinationen von einer variablen Anzahl von Items ausspuckt. Jedes Item hat die gleiche Anzahl an verschiedenen Werten.<br />
Also letztendlich bei z.B. 3 Items und 10 Werten<br />
1 1 1<br />
1 1 2<br />
. . .<br />
5 6 9<br />
. . .<br />
10 10 10</p>
<p>und das ganze variabel für n Items und m Werten</p>
<p>ich vermute mal ich muss das rekursiv programmieren steh aber aufm Schlauch wie das gehen kann.</p>
<p>Könnt ihr mir da nen Anreiz geben?</p>
<p>Viele Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212257</guid><dc:creator><![CDATA[BigBang2012]]></dc:creator><pubDate>Wed, 16 May 2012 14:02:43 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Wed, 16 May 2012 14:06:02 GMT]]></title><description><![CDATA[<p>Wenn ich deine Beispiel mal etwas anders umschreibe (3 Items, 10 Werte):<br />
0 0 0<br />
0 0 1<br />
0 0 2<br />
...<br />
0 0 9<br />
0 1 0<br />
0 1 1<br />
...<br />
9 9 9</p>
<p>fällt dir dann etwas auf?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212261</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 16 May 2012 14:06:02 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Wed, 16 May 2012 14:31:10 GMT]]></title><description><![CDATA[<p>nein nicht direkt, nur das das halt einfach von 0 bis 999 zählt, aber das funzt ja nicht bei zum Beispiel 123 Werten...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212275</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212275</guid><dc:creator><![CDATA[Bigbang2012]]></dc:creator><pubDate>Wed, 16 May 2012 14:31:10 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Wed, 16 May 2012 14:49:05 GMT]]></title><description><![CDATA[<p>Tipp: for-Schleife(n)!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212296</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Wed, 16 May 2012 14:49:05 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Wed, 16 May 2012 15:16:49 GMT]]></title><description><![CDATA[<p>Bigbang2012 schrieb:</p>
<blockquote>
<p>nein nicht direkt, nur das das halt einfach von 0 bis 999 zählt, aber das funzt ja nicht bei zum Beispiel 123 Werten...</p>
</blockquote>
<p>Ich zähle mal mit 16 Werten:<br />
0 0<br />
0 1<br />
...<br />
0 9<br />
0 A<br />
...<br />
0 F<br />
1 0<br />
...<br />
F F</p>
<p>Macht's nun Klick?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212311</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 16 May 2012 15:16:49 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Wed, 16 May 2012 15:27:31 GMT]]></title><description><![CDATA[<p>Ist wie bei Kilometerzaehler ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212316</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Wed, 16 May 2012 15:27:31 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 07:10:40 GMT]]></title><description><![CDATA[<p>musst du die fkt selbst bauen?<br />
oder kannst du auch std::next_permutation nutzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212476</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Thu, 17 May 2012 07:10:40 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 07:18:34 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>musst du die fkt selbst bauen?<br />
oder kannst du auch std::next_permutation nutzen?</p>
</blockquote>
<p>std::next_permutation ist nicht die Loesung des Problems.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212477</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 17 May 2012 07:18:34 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 07:29:32 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>unskilled schrieb:</p>
<blockquote>
<p>musst du die fkt selbst bauen?<br />
oder kannst du auch std::next_permutation nutzen?</p>
</blockquote>
<p>std::next_permutation ist nicht die Loesung des Problems.</p>
</blockquote>
<p>und sicher nicht die effektivste, wenn man nur 0-F als mögliche werte hat, ja.<br />
für 0-[&gt;F] fällt mir allerdings gerad nix anderes ein</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212482</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Thu, 17 May 2012 07:29:32 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 09:17:42 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>knivil schrieb:</p>
<blockquote>
<p>unskilled schrieb:</p>
<blockquote>
<p>musst du die fkt selbst bauen?<br />
oder kannst du auch std::next_permutation nutzen?</p>
</blockquote>
<p>std::next_permutation ist nicht die Loesung des Problems.</p>
</blockquote>
<p>und sicher nicht die effektivste, wenn man nur 0-F als mögliche werte hat, ja.<br />
für 0-[&gt;F] fällt mir allerdings gerad nix anderes ein</p>
</blockquote>
<p>Ich muss wohl mit den subtilen Tipps aufhören.</p>
<p>Dann eben die Lösung, da Ratschläge anscheinend nicht funktionieren: Der Threadersteller beschreibt das Zählen in einem b-adischen Zahlensystem mit N Stellen. Dabei ist b die Anzahl der &quot;Werte&quot; und N die Anzahl der &quot;Items&quot;. Man braucht also bloß eine einzelne Schleife die von 0 bis (b^N)-1 zählt, die gesuchten Kombinationen sind dabei die Darstellung des Zähler im b-adischen System (klingt kompliziert ist aber nur allgemeine Transformation zwischen Ziffensystemen anwenden, ganz einfach). Ob man die Ziffern dabei '0' bis 'F' bezeichnet oder '1' bis '10' oder sie nach den eigenen Lieblingstransformers benennt, ist Wurst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212494</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 17 May 2012 09:17:42 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 10:24:47 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;ostream&gt;
#include &lt;vector&gt;
#include &lt;iterator&gt;
#include &lt;algorithm&gt;

using namespace std;

/// interpretiert den Vektor 'was' als Darstellung einer Zahl im
/// Stellenwertsystem zur Basis 'basis' (\sum_k was[k] * basis^k)
/// und inkrementiert diese Zahl um eins. Ein Überlauf wird per
/// Rückgabewert true signalisiert.
bool inkrementiere(vector&lt;int&gt; &amp; was, int basis);

int main()
{
	const int basis   = 10;
	const int stellen = 3;
	vector&lt;int&gt; z (stellen);
	do {
		copy(z.begin(),z.end(),ostream_iterator&lt;int&gt;(cout,&quot; &quot;));
		cout &lt;&lt; endl;
	} while (!inkrementiere(z,basis));
}
</code></pre>
<p>Kommst Du drauf, wie inkrementiere auszusehen hat?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212504</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 17 May 2012 10:24:47 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 10:47:48 GMT]]></title><description><![CDATA[<p>Warum so kompliziert? Ist das nicht einfach wie bei einem Zahlenschloss? Also<br />
Anzahl der Werte^Anzahl möglicher Items^ ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212506</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Thu, 17 May 2012 10:47:48 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 10:58:08 GMT]]></title><description><![CDATA[<p>Natürlich ist das so, und jetzt überlege mal, was ein Zahlenschloss ist. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212509</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Thu, 17 May 2012 10:58:08 GMT</pubDate></item><item><title><![CDATA[Reply to Alle Kombinationen mit variabler Anzahl von Items on Thu, 17 May 2012 21:12:27 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p>Natürlich ist das so, und jetzt überlege mal, was ein Zahlenschloss ist. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Ein Kilometerzaehler ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2212668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2212668</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 17 May 2012 21:12:27 GMT</pubDate></item></channel></rss>