<?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[Bitte um Erklärung]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
using namespace std;

void hanoi (int n, int A, int B, int C) {

if (n&gt;0) {

hanoi(n - 1, A, C, B);

cout &lt;&lt; &quot;Trage oberste Scheibe von &quot; &lt;&lt; A &lt;&lt; &quot; nach &quot; &lt;&lt; C &lt;&lt; endl;

hanoi(n - 1, B, A, C);

}
}

int main ()
{
int n;
cout &lt;&lt; &quot;Scheibennummer: &quot;;
cin &gt;&gt; n;

hanoi(n, 1, 2, 3);

return 0;
}
</code></pre>
<p>kann mir hier jemand den Ablauf erklären? das int main() versteh ich schon. und das die zahlen ans void übertragen werden. nur was passiert nachher? zum beispiel für n=3.</p>
<p>zunächst springt er von zeile 10 so oft in 5 bis n=0 ist? hab ich das richtig verstanden? nacher steht &quot;Trage oberste Scheibe von 1 nach 3.&quot;<br />
nur wenn jetzt n=0 ist wie geht es weiter?</p>
<p>bitte um Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/198938/bitte-um-erklärung</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 18:26:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198938.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Nov 2007 10:25:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 10:25:16 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
using namespace std;

void hanoi (int n, int A, int B, int C) {

if (n&gt;0) {

hanoi(n - 1, A, C, B);

cout &lt;&lt; &quot;Trage oberste Scheibe von &quot; &lt;&lt; A &lt;&lt; &quot; nach &quot; &lt;&lt; C &lt;&lt; endl;

hanoi(n - 1, B, A, C);

}
}

int main ()
{
int n;
cout &lt;&lt; &quot;Scheibennummer: &quot;;
cin &gt;&gt; n;

hanoi(n, 1, 2, 3);

return 0;
}
</code></pre>
<p>kann mir hier jemand den Ablauf erklären? das int main() versteh ich schon. und das die zahlen ans void übertragen werden. nur was passiert nachher? zum beispiel für n=3.</p>
<p>zunächst springt er von zeile 10 so oft in 5 bis n=0 ist? hab ich das richtig verstanden? nacher steht &quot;Trage oberste Scheibe von 1 nach 3.&quot;<br />
nur wenn jetzt n=0 ist wie geht es weiter?</p>
<p>bitte um Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410849</guid><dc:creator><![CDATA[deiwid]]></dc:creator><pubDate>Tue, 27 Nov 2007 10:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 10:29:38 GMT]]></title><description><![CDATA[<p>Schlag mal den Begriff &quot;Rekursion&quot; nach, da solltest du die Erklärung finden (und die Türme von Hanoi sind eins der beliebtesten Beispiele für Rekursion). Die Funktion ruft sich selber mit etwas anderen Parametern auf und gibt zwischendurch etwas aus - bei n==0 kehrt sie sofort zurück, ohne etwas zu machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410854</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 27 Nov 2007 10:29:38 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 11:36:47 GMT]]></title><description><![CDATA[<p>aaaah jetzt versteh ich, vielen dank!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410896</guid><dc:creator><![CDATA[deiwid]]></dc:creator><pubDate>Tue, 27 Nov 2007 11:36:47 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 12:01:00 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Schlag mal den Begriff &quot;Rekursion&quot; nach, ...</p>
</blockquote>
<p>Das muss nicht unbedingt weiterhelfen. Ich hatte letztens in einem Nachschlagewerk nur die Erklärung:</p>
<blockquote>
<p><strong>Rekursion</strong>: <em>(die, Hauptwort)</em>; siehe Rekursion.</p>
</blockquote>
<p>Ist zwar zutreffend, aber wohl nicht für jedermann verständlich.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410911</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 27 Nov 2007 12:01:00 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 12:02:33 GMT]]></title><description><![CDATA[<p>Simon2 schrieb:</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>Schlag mal den Begriff &quot;Rekursion&quot; nach, ...</p>
</blockquote>
<p>Das muss nicht unbedingt weiterhelfen. Ich hatte letztens in einem Nachschlagewerk nur die Erklärung:</p>
<blockquote>
<p><strong>Rekursion</strong>: <em>(die, Hauptwort)</em>; siehe Rekursion.</p>
</blockquote>
<p>Ist zwar zutreffend, aber wohl nicht für jedermann verständlich.</p>
<p>Gruß,</p>
<p>Simon2.</p>
</blockquote>
<p>Echt, das gibt's wirklich? Was für ein Buch war das denn? (ich hab das bisher immer für einen Insider-Witz gehalten)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410912</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 27 Nov 2007 12:02:33 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 12:35:09 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>...Echt, das gibt's wirklich? Was für ein Buch war das denn? (ich hab das bisher immer für einen Insider-Witz gehalten)</p>
</blockquote>
<p>Ich habe schon krampfhaft gesucht, es aber nicht mehr gefunden. Aber ich bin sicher, dass ich es wirklich gesehen habe ...</p>
<p>EDIT: Ja hier hab ich's:</p>
<p>Herb Sutter: Exceptional C++ Style; Index schrieb:</p>
<blockquote>
<p>recursion: see recursion.</p>
</blockquote>
<p>(meine aber, es auch noch woanders gesehen zu haben)</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410924</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410924</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 27 Nov 2007 12:35:09 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 12:34:07 GMT]]></title><description><![CDATA[<p>Im Katalog der Bibliothek von Phatt Island bei Monkey Island 2, aber das zählt wahrscheinlich nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1410930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1410930</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Tue, 27 Nov 2007 12:34:07 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 14:16:04 GMT]]></title><description><![CDATA[<p>ok, hab ein wenig nachgelesen. hilft nicht besonders viel. aber ich versteh schon mehr.</p>
<p>hab ein mal paar tests gemacht. für n=3</p>
<pre><code>void hanoi (int n, int A, int B, int C) {

cout &lt;&lt; n ;

if (n&gt;0) {

hanoi(n - 1, A, C, B);

cout &lt;&lt; &quot;Trage oberste Scheibe von &quot; &lt;&lt; A &lt;&lt; &quot; nach &quot; &lt;&lt; C &lt;&lt; endl;
cout &lt;&lt; n ;

hanoi(n - 1, B, A, C);
</code></pre>
<p>Ausgabe:<br />
3210Trage oberste Scheibe von 1 nach 3<br />
10Trage oberste Scheibe von 1 nach 2<br />
210Trage oberste Scheibe von 3 nach 2<br />
10Trage oberste Scheibe von 1 nach 3<br />
3210Trage oberste Scheibe von 2 nach 1<br />
10Trage oberste Scheibe von 2 nach 3<br />
210Trage oberste Scheibe von 1 nach 3<br />
10</p>
<p>so mein frage: wie kommt man bei der 3.Ausgabe auf den ersten 2er?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1411031</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1411031</guid><dc:creator><![CDATA[deiwid]]></dc:creator><pubDate>Tue, 27 Nov 2007 14:16:04 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Erklärung on Tue, 27 Nov 2007 14:24:19 GMT]]></title><description><![CDATA[<p>Vielleicht solltest du dir wirklich mal klarmachen, in welcherReihenfolge die Funktion mit welchen Parametern ausgeführt wird - und wann sie welche Ausgaben macht:</p>
<pre><code>hanoi(3,1,2,3)
  hanoi(2,1,3,2)
    hanoi(1,1,2,3)
      hanoi(0,1,3,2)
      cout&lt;&lt; 1-&gt;3
      hanoi(0,2,1,3)
    cout&lt;&lt; 1-&gt;2
    hanoi(1,3,1,2)
      hanoi(0,1,3,2)
      cout&lt;&lt; 3-&gt;2
      hanoi(0,1,3,2)
  cout&lt;&lt; 1-&gt;2
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1411042</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1411042</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 27 Nov 2007 14:24:19 GMT</pubDate></item></channel></rss>