<?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[Permutation]]></title><description><![CDATA[<p>Hallo,</p>
<p>im Artikel</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-178286.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-178286.html</a></p>
<p>wird beschrieben wie ich die Permutation in einer gegebenen Menge mit allen Kombinationen implementieren kann.</p>
<blockquote>
<pre><code class="language-cpp">// ============================================================================
// Function:    SSTL_Permutation
// Description: Generate all permuted strings for an input string using
//              original STL function next_permutation().
// Parameter:   @input: the input string.
// Return:      A vector of all permuted strings.
// Note:        STL next_permutation permutes the string input to the
//              lexicographically next string as an arrangement, and then
//              returns true. Due to this reason, the STL function stable_sort
//              is called before.
// ============================================================================
vector&lt;string&gt; SSTL_Permutation(const char *input)
{
    vector&lt;string&gt; result;
    string cs = input;

    stable_sort(cs.begin(), cs.end());  

    do  
        result.insert(result.end(), cs);
    while(next_permutation(cs.begin(), cs.end()));

    return result;
}
</code></pre>
</blockquote>
<p>Mein Problem ist, wie kann ich in einer gegeben Menge alle Permutationen von Dreierkombinationen ermitteln? Also als Beispiel:</p>
<p>Ich habe 20 Punkte und möchte alle 3 Kombinationen dieser 20 Punkte ermitteln.</p>
<p>(P_1,P_2,P_3) (P_1,P_2,P_4) (P_1,P_2,P_5) ...</p>
<p>Wobei (P_1,P_2,P_3) und (P_3,P_2,P_1) das selbe ist. Also geordnet und ohne Wiederholung.<br />
Welche Bedingung muss ich mit einbauen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/221067/permutation</link><generator>RSS for Node</generator><lastBuildDate>Tue, 06 Oct 2026 12:08:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/221067.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Aug 2008 10:19:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 10:19:52 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>im Artikel</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-178286.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-178286.html</a></p>
<p>wird beschrieben wie ich die Permutation in einer gegebenen Menge mit allen Kombinationen implementieren kann.</p>
<blockquote>
<pre><code class="language-cpp">// ============================================================================
// Function:    SSTL_Permutation
// Description: Generate all permuted strings for an input string using
//              original STL function next_permutation().
// Parameter:   @input: the input string.
// Return:      A vector of all permuted strings.
// Note:        STL next_permutation permutes the string input to the
//              lexicographically next string as an arrangement, and then
//              returns true. Due to this reason, the STL function stable_sort
//              is called before.
// ============================================================================
vector&lt;string&gt; SSTL_Permutation(const char *input)
{
    vector&lt;string&gt; result;
    string cs = input;

    stable_sort(cs.begin(), cs.end());  

    do  
        result.insert(result.end(), cs);
    while(next_permutation(cs.begin(), cs.end()));

    return result;
}
</code></pre>
</blockquote>
<p>Mein Problem ist, wie kann ich in einer gegeben Menge alle Permutationen von Dreierkombinationen ermitteln? Also als Beispiel:</p>
<p>Ich habe 20 Punkte und möchte alle 3 Kombinationen dieser 20 Punkte ermitteln.</p>
<p>(P_1,P_2,P_3) (P_1,P_2,P_4) (P_1,P_2,P_5) ...</p>
<p>Wobei (P_1,P_2,P_3) und (P_3,P_2,P_1) das selbe ist. Also geordnet und ohne Wiederholung.<br />
Welche Bedingung muss ich mit einbauen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1570926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1570926</guid><dc:creator><![CDATA[Mister Wing]]></dc:creator><pubDate>Mon, 25 Aug 2008 10:19:52 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 11:00:02 GMT]]></title><description><![CDATA[<p>Hm, geht es auch ohne STL?<br />
Finde ich einfacher. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1570960</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1570960</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Mon, 25 Aug 2008 11:00:02 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 11:11:09 GMT]]></title><description><![CDATA[<p>Such mal nach Passwort-Cracker, solltest sogar hier im Forum fündig werden. Diese Art von Permutation wird dort benötigt und Codes die so einen implementieren findet man zur genüge <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1570969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1570969</guid><dc:creator><![CDATA[Tippgeber]]></dc:creator><pubDate>Mon, 25 Aug 2008 11:11:09 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 14:22:28 GMT]]></title><description><![CDATA[<p>Tippgeber schrieb:</p>
<blockquote>
<p>Such mal nach Passwort-Cracker, solltest sogar hier im Forum fündig werden. Diese Art von Permutation wird dort benötigt und Codes die so einen implementieren findet man zur genüge <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>Willst du damit sagen, dass die Passwörter &quot;abcd&quot; und &quot;dcba&quot; gleichwertig sind?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571143</guid><dc:creator><![CDATA[Nanyuki]]></dc:creator><pubDate>Mon, 25 Aug 2008 14:22:28 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 14:28:56 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">vector&lt;string&gt; nonSSTL_Permutation(const char *input)
{
    vector&lt;string&gt; result;
    string cs(input);
    stable_sort(cs.begin(), cs.end());  

    int length = cs.length();
    for(int i = 0; i &lt; length - 2, i++)
      for(int ii = i + 1; ii &lt; length - 1; ii++)
        for(int iii = ii + 1; iii &lt; length; iii++)
          result.push_back(string(cs[i]) + cs[ii] + cs[iii]);

    return result;
}
</code></pre>
<p>Geht mit Templates wohl noch einfacher aber so geht es auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571149</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Mon, 25 Aug 2008 14:28:56 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 14:51:21 GMT]]></title><description><![CDATA[<p>Es muss aber geordnet sein. Demzufolge dürfen auch keine Wiederholungen enthalten sein.<br />
Bei deinem Beispiel ist &quot;abcd&quot; und &quot;dcba&quot; das selbe, sprich eine Wiederholung.<br />
Wenn ich also aus 4 Buchstaben alle Permutationen ohne Wiederholung erstelle, sollte es nur eine Möglichkeit geben, nämliche eine. -&gt; &quot;abcd&quot;<br />
Nun zurück zu meine Problemestellung. Ich möchte beispielsweise aus &quot;abcd&quot; alle Dreierkombinationen bilden.</p>
<p>&quot;abc&quot; &quot;abd&quot; &quot;bcd&quot; &quot;acd&quot;</p>
<p>Wie kann ich das nun sinnvoll umsetzen?</p>
<blockquote>
<pre><code class="language-cpp">vector&lt;string&gt; nonSSTL_Permutation(const char *input)
{
    vector&lt;string&gt; result;
    string cs(input);
    stable_sort(cs.begin(), cs.end());  

    int length = cs.length();
    for(int i = 0; i &lt; length - 2, i++)
      for(int ii = i + 1; ii &lt; length - 1; ii++)
        for(int iii = ii + 1; iii &lt; length; iii++)
          result.push_back(string(cs[i]) + cs[ii] + cs[iii]);

    return result;
}
</code></pre>
</blockquote>
<p>Wie kann ich in der dritten Schleife die Bedingung setzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571159</guid><dc:creator><![CDATA[Mister Wing]]></dc:creator><pubDate>Mon, 25 Aug 2008 14:51:21 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Mon, 25 Aug 2008 15:25:07 GMT]]></title><description><![CDATA[<p>Nanyuki schrieb:</p>
<blockquote>
<p>Tippgeber schrieb:</p>
<blockquote>
<p>Such mal nach Passwort-Cracker, solltest sogar hier im Forum fündig werden. Diese Art von Permutation wird dort benötigt und Codes die so einen implementieren findet man zur genüge <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>Willst du damit sagen, dass die Passwörter &quot;abcd&quot; und &quot;dcba&quot; gleichwertig sind?</p>
</blockquote>
<p>Nein, das habe ich überlesen. Macht die Sache sogar einfacher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571185</guid><dc:creator><![CDATA[Tippgeber]]></dc:creator><pubDate>Mon, 25 Aug 2008 15:25:07 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Tue, 26 Aug 2008 08:32:42 GMT]]></title><description><![CDATA[<p>Mister Wing schrieb:</p>
<blockquote>
<p>Wie kann ich in der dritten Schleife die Bedingung setzen?</p>
</blockquote>
<p>Welche Bedingung? Funzt doch. Zumindest wenn man meine Flüchtigkeitsfehler rausnimmt.</p>
<p>Nichts doppelt und auch sortiert.</p>
<pre><code class="language-cpp">vector&lt;string&gt; nonSSTL_Permutation(const char *input)
{
    vector&lt;string&gt; result;
    string cs(input);
    stable_sort(cs.begin(), cs.end());  

    int length = cs.length();
    for(int i = 0; i &lt; length - 2; i++)
      for(int ii = i + 1; ii &lt; length - 1; ii++)
        for(int iii = ii + 1; iii &lt; length; iii++)
          result.push_back(string() + cs[i] + cs[ii] + cs[iii]);

    return result;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1571536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571536</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Tue, 26 Aug 2008 08:32:42 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Tue, 26 Aug 2008 09:02:10 GMT]]></title><description><![CDATA[<p>Funktioniert jetzt hald nur für 3 aus 4... So wie ich das sehe.<br />
Matlab?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571565</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571565</guid><dc:creator><![CDATA[Gerold P]]></dc:creator><pubDate>Tue, 26 Aug 2008 09:02:10 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Tue, 26 Aug 2008 09:14:23 GMT]]></title><description><![CDATA[<p>Gerold P schrieb:</p>
<blockquote>
<p>Funktioniert jetzt hald nur für 3 aus 4... So wie ich das sehe.<br />
Matlab?</p>
</blockquote>
<p>Funktioniert auch für 3 aus 1.000.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571568</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Tue, 26 Aug 2008 09:14:23 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation on Tue, 26 Aug 2008 09:21:07 GMT]]></title><description><![CDATA[<p>Wie schon gesagt, habs nicht ausprobiert, hab auch meinen C Compiler jetzt gelöscht.</p>
<p>Dachte nur wegen dem &quot; Length - 2 &quot; aber hab jetzt keien Lust drüber nachzudenken.</p>
<p>War nicht bös gemeint.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1571571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1571571</guid><dc:creator><![CDATA[Gerold P.]]></dc:creator><pubDate>Tue, 26 Aug 2008 09:21:07 GMT</pubDate></item></channel></rss>