<?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 of Array]]></title><description><![CDATA[<p>Hallo,</p>
<p>printPermuation of Array. Mal Hand aufs Herz ist der Algorithmus einfach oder schwer. Auf ner Skala von 1 bis 5 würde ich sagen sau schwer = 5 .</p>
<p>z.B. int* arr [3] = {1,2,3};</p>
<p>Ausgabe 1 2 3<br />
1 3 2<br />
2 1 3<br />
2 3 1<br />
3 1 2<br />
3 2 1</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/331836/permutation-of-array</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 04:00:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/331836.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Mar 2015 23:37:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Permutation of Array on Sun, 22 Mar 2015 23:37:55 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>printPermuation of Array. Mal Hand aufs Herz ist der Algorithmus einfach oder schwer. Auf ner Skala von 1 bis 5 würde ich sagen sau schwer = 5 .</p>
<p>z.B. int* arr [3] = {1,2,3};</p>
<p>Ausgabe 1 2 3<br />
1 3 2<br />
2 1 3<br />
2 3 1<br />
3 1 2<br />
3 2 1</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447664</guid><dc:creator><![CDATA[StudiProf]]></dc:creator><pubDate>Sun, 22 Mar 2015 23:37:55 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Sun, 22 Mar 2015 23:50:32 GMT]]></title><description><![CDATA[<p>Was hat das mit C++ zu tun? Was ist deine Frage? Willst du Mitleid? Eine Lösung deiner Hausaufgaben? Ich weiß nicht, welchen Algorithmus du meinst, aber es gibt einen, der wäre eine 1 auf deiner Skala. Eher schon eine 0.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447667</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 22 Mar 2015 23:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Sun, 22 Mar 2015 23:58:25 GMT]]></title><description><![CDATA[<blockquote>
<p>Ich weiß nicht, welchen Algorithmus du meinst, aber es gibt einen, der wäre eine 1 auf deiner Skala. Eher schon eine 0.</p>
</blockquote>
<p>Ich würde ihm eine zwei geben.</p>
<pre><code>template&lt;class BidirIt&gt;
bool next_permutation(BidirIt first, BidirIt last)
{
    if (first == last) return false;
    BidirIt i = last;
    if (first == --i) return false;

    while (1) {
        BidirIt i1, i2;

        i1 = i;
        if (*--i &lt; *i1) {
            i2 = last;
            while (!(*i &lt; *--i2))
                ;
            std::iter_swap(i, i2);
            std::reverse(i1, last);
            return true;
        }
        if (i == first) {
            std::reverse(first, last);
            return false;
        }
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2447670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447670</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sun, 22 Mar 2015 23:58:25 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 00:17:55 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<p>Ich würde ihm eine zwei geben.</p>
</blockquote>
<p>Deiner ist ja auch wesentlich komplizierter, als das, was ich machen würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447673</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 23 Mar 2015 00:17:55 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 01:18:53 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19375">@SeppJ</a><br />
Weiss nicht ob das &quot;seiner&quot; ist...<br />
<a href="http://en.cppreference.com/w/cpp/algorithm/next_permutation" rel="nofollow">http://en.cppreference.com/w/cpp/algorithm/next_permutation</a><br />
<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>
<p>----</p>
<p>Funktioniert dein &quot;einser&quot; Algorithmus auch wenn es Duplikate in dem Array gibt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447674</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447674</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 01:18:53 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 01:40:53 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Funktioniert dein &quot;einser&quot; Algorithmus auch wenn es Duplikate in dem Array gibt?</p>
</blockquote>
<p>Kommt drauf an, welches Ergebnis du in dem Fall wünscht. Mein Algorithmus glaubt nicht an die Ununterscheidbarkeit gleicher Werte <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/2447675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447675</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 23 Mar 2015 01:40:53 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 01:44:30 GMT]]></title><description><![CDATA[<p>Gut, ich wollte nur wissen was du meinst.<br />
Denn ein &quot;Einser&quot; der doch an die Ununterscheidbarkeit gleicher Werte glaubt fällt mir nicht ein.<br />
Und falls du einen kennst, hätte mich der schon interessiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447676</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 01:44:30 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 01:49:13 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19375">@SeppJ</a>: Listet deiner denn alle in Reihenfolge auf? Und funktioniert für beliebige Mengen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447677</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 23 Mar 2015 01:49:13 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 02:08:46 GMT]]></title><description><![CDATA[<p>Mir fällt</p>
<pre><code>void list_permutations( int* arr, std::size_t len, std::size_t previous_len=0 ) {
	if (len==1) {
		while (previous_len--)
			std::cout &lt;&lt; *arr--;
		std::cout &lt;&lt; *arr &lt;&lt; std::endl;
		return;
	}

	for (std::size_t p = 0; p != len; ++p) {
		std::iter_swap(arr, arr+p);
		list_permutations(arr+1, len-1, previous_len+1);
		std::iter_swap(arr, arr+p);
	}
}
</code></pre>
<p>ein - ist aber IMO keine 1.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447678</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 23 Mar 2015 02:08:46 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 02:11:16 GMT]]></title><description><![CDATA[<p>&quot;Für beliebige Mengen&quot; finde ich eine komische Forderung, da der <code>next_permutation</code> der STL (den du ja gezeigt hast) gerade <em>nicht</em> für beliebige Mengen funktioniert. Schliesslich wird vorausgesetzt dass die Elemente sortierbar sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447679</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 02:11:16 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 02:18:54 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Schliesslich wird vorausgesetzt dass die Elemente sortierbar sind.</p>
</blockquote>
<p>Ich dachte eher daran dass es nicht um Ganzzahlmengen mit lediglich konsekutiven Elementen geht, die auch noch mit 1 beginnen.</p>
<blockquote>
<p>&quot;Für beliebige Mengen&quot; finde ich eine komische Forderung, da der <code>next_permutation</code> der STL (den du ja gezeigt hast) gerade <em>nicht</em> für beliebige Mengen funktioniert.</p>
</blockquote>
<p>Ich stelle eine Forderung an seine Implementierung. Was hat mein gepasteter Code damit überhaupt zu tun? Den nahm ich lediglich zum vorzeigen der Komplexität.<br />
Edit: Gut, ich hätte erwähnen sollen dass ich <code>next_permutation</code> nicht als tatsächlichen Kandidat vorschlug. Mea culpa.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447680</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 23 Mar 2015 02:18:54 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 03:39:41 GMT]]></title><description><![CDATA[<p>Ja, geht für beliebige Arten von Daten. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Verstehe ich da gerade richtig? Das ist irgendwie eine komische Anforderung.</p>
<p>Welches ist <strong>die</strong> Reihenfolge?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447683</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447683</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 23 Mar 2015 03:39:41 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 10:30:46 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Welches ist <strong>die</strong> Reihenfolge?</p>
</blockquote>
<p>Offensichtlich wäre es nicht schlecht wenn die Permutationen in lexikographischer Reihenfolge durchlaufen werden.</p>
<blockquote>
<p>Verstehe ich da gerade richtig? Das ist irgendwie eine komische Anforderung.</p>
</blockquote>
<p>Mir geht es darum dass dein Algo kein Spezialisierter ist, der lediglich die Permutationen der ersten N natürlichen Zahlen ausgibt. Es soll ein allgemeiner Algo sein. Wenn deiner tatsächlich allgemeine ist, wie soll er dann den in meinem obigen Post in Einfachheit übertreffen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447698</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 23 Mar 2015 10:30:46 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 12:14:17 GMT]]></title><description><![CDATA[<p>Angenommen ihr bekommt in einem Test die Aufgabe diesen Algorithmus zu implementieren. Wie schwer findet ihr das ? Um das gings mir eigentlich <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="🙂"
    /><br />
Leicht, Schwer, Sauschwer</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447712</guid><dc:creator><![CDATA[StudiProf]]></dc:creator><pubDate>Mon, 23 Mar 2015 12:14:17 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 16:06:04 GMT]]></title><description><![CDATA[<p>@StudiProf<br />
Kommt auf den Kenntnisstand der Schüler drauf an, und natürlich darauf wie lange sie dafür Zeit haben.<br />
Im ersten Semester von so ziemlich egal was würde ich die Frage schwer nennen. Für Informatiker im 2 Studienabschnitt ist sie eher mittel bis leicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447727</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 16:06:04 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 16:50:55 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19375">@SeppJ</a>: Bekommen wir deinen Algo auch zu sehen? Oder muss das Meisterwerk erst patentiert werden? <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="😃"
    /><br />
Edit: Verdammt, das Internet hat mich ungeduldig gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447736</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 23 Mar 2015 16:50:55 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 16:56:27 GMT]]></title><description><![CDATA[<p>Also ich vermute dass genau der<br />
<a href="https://www.c-plusplus.net/forum/p2447678#2447678">https://www.c-plusplus.net/forum/p2447678#2447678</a><br />
gemeint war.</p>
<p>Mir zumindest fällt nix einfacheres ein.<br />
Und wenn <code>std::next_permutation</code> für dich ne 2 ist, dann wundert es mich dass du das nicht als 1 durchgehen lässt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447738</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 16:56:27 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 18:26:28 GMT]]></title><description><![CDATA[<p>1 heißt &quot;trivial&quot;. Das ist aber IMO kein trivialer Algo.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447756</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 23 Mar 2015 18:26:28 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 18:35:36 GMT]]></title><description><![CDATA[<p>Das ist trivial. next_permutation ist vielleicht eine 2, aber einfach nur alle Permutationen ist eine 1.</p>
<p>Hier ein Code im Anfängerstil:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;algorithm&gt;
using namespace std;

void permprint(int *arr, int size, int curr=0) {
	if (curr+1 &gt;= size) {
		for (int i=0; i&lt;size; ++i)
			cout &lt;&lt; arr[i] &lt;&lt; ' ';
		cout &lt;&lt; '\n';
	} else {
		for (int i=curr; i&lt;size; ++i) {
			swap(arr[curr], arr[i]);
			permprint(arr, size, curr+1);
			swap(arr[curr], arr[i]);
		}
	}
}

int main() {
	int arr[] = {1, 2, 3, 4};
	permprint(arr, 4);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2447758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447758</guid><dc:creator><![CDATA[trivialo]]></dc:creator><pubDate>Mon, 23 Mar 2015 18:35:36 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 18:43:07 GMT]]></title><description><![CDATA[<p>Ich möchte noch einmal unterstreichen:</p>
<p>SeppJ schrieb:</p>
<blockquote>
<p>hustbaer schrieb:</p>
<blockquote>
<p>Funktioniert dein &quot;einser&quot; Algorithmus auch wenn es Duplikate in dem Array gibt?</p>
</blockquote>
<p>Kommt drauf an, welches Ergebnis du in dem Fall wünscht. Mein Algorithmus glaubt nicht an die Ununterscheidbarkeit gleicher Werte <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>
</blockquote>
<p>Aufgrund der undeutlichen Fragestellung dachte ich, es würde etwas erwartet, das aus der Menge {1, 1, 2} die Ausgabe<br />
1 1 2<br />
1 2 1<br />
1 1 2<br />
1 2 1<br />
2 1 1<br />
2 1 1<br />
generiert. Fällt euch jetzt eine triviale Umsetzung ein, die wirklich ein 0 verdient?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447761</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447761</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 23 Mar 2015 18:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 21:55:35 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Fällt euch jetzt eine triviale Umsetzung ein, die wirklich ein 0 verdient?</p>
</blockquote>
<p>Mir nicht.<br />
Ich wüsste nicht wie man den von Arcoth bzw. auch trivialo implementierten Algorithmus noch weiter vereinfachen könnte.<br />
Will sehen! <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/2447791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447791</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 21:55:35 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 23:24:25 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Ich wüsste nicht wie man den von Arcoth bzw. auch trivialo implementierten Algorithmus noch weiter vereinfachen könnte.<br />
Will sehen! <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>Ich meine den von trivialo bzw. den zweiten von Arcoth. Das ist in meinen Augen wesentlich einfacher als die Nummer 1 von Arcoth und verdient eine 1 oder weniger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447813</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 23 Mar 2015 23:24:25 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 23:25:43 GMT]]></title><description><![CDATA[<p>Also ich hab nen Bachelor in Informatik und ich bin zu blöd den Algorithmus hinzukriegen. Also einfach ist das sicher nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447815</guid><dc:creator><![CDATA[BabsiRu]]></dc:creator><pubDate>Mon, 23 Mar 2015 23:25:43 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Mon, 23 Mar 2015 23:32:46 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19375">@SeppJ</a><br />
Ich dachte dass du was anderes meinst, da dieser Algorithmus ja bereits 2x gepostet wurde bevor du gefragt hast ob uns was einfaches einfällt.</p>
<p>Dass Arcoth den für &quot;schwerer als 1&quot; hält hat er ja schon geschreiben.</p>
<p>Ich würde ihm ne 1 geben. Ne 0 finde ich übertrieben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2447818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447818</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Mar 2015 23:32:46 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Tue, 24 Mar 2015 00:10:45 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19375">@SeppJ</a><br />
Ich dachte dass du was anderes meinst, da dieser Algorithmus ja bereits 2x gepostet wurde bevor du gefragt hast ob uns was einfaches einfällt.</p>
</blockquote>
<p>trivialo hat geantwortet, während ich meine Antwort formuliert habe und Arcoths iter_swap-Code habe ich nicht wirklich gelesen. Zu anstrengend.</p>
<p>Wenn man will, kann man die gleiche Idee auch noch einfacher formulieren, wobei es aber für den Computer aufwändiger wird:</p>
<pre><code>template&lt;typename Vector&gt; void print_combinations(Vector data, Vector history)
{
  if (data.empty())
    {
      for (const auto&amp; e: history)
        std::cout &lt;&lt; e &lt;&lt; '\t';
      std::cout &lt;&lt; '\n';
    }
  else
    {
      for (std::size_t i = 0; i &lt; data.size(); ++i)
        {
          auto new_data = data;
          auto new_history = history;
          new_data.erase(new_data.begin() + i);
          new_history.push_back(data[i]);
          print_combinations(new_data, new_history);
        }
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2447822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447822</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 24 Mar 2015 00:10:45 GMT</pubDate></item><item><title><![CDATA[Reply to Permutation of Array on Tue, 24 Mar 2015 22:47:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab jetzt mal den Algo gefunden . Ist der gut ? Leider versteh ich den überhaupt nicht. Allgemein hab ich große Probleme mit Rekursion. Sollte man sich das am besten mathematisch herleiten ?</p>
<pre><code>void permute(int k,int size){
    int i;

    if (k==0)
        printArray(size);
    else{
        for (i=k-1;i&gt;=0;i--){
            swap(i,k-1);
            permute(k-1,size);
            swap(i,k-1);
        }
    }

    return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2447919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2447919</guid><dc:creator><![CDATA[NullPlanProf]]></dc:creator><pubDate>Tue, 24 Mar 2015 22:47:53 GMT</pubDate></item></channel></rss>