<?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[wer kanns erklären??]]></title><description><![CDATA[<p>Bin Neuling, vielleicht kann mit jemand folgendes erklären:<br />
Das ist mein Struct:</p>
<p>struct zustand_note<br />
{<br />
std::vector&lt;int&gt; werte; // die Zahlen in einen Vektor verpackt<br />
zustand_note *next; // Verknüpfung zum Nachfolger<br />
};<br />
zustand_note *anker = 0; // Anfang der Liste</p>
<p>ein Vektor zum Speichern von intWerten und ein Zeiger auf das nächste Element von Struct.<br />
2 Funktionen:<br />
void zustand_note_ausgeben(zustand_note zx)<br />
{<br />
std::cout &lt;&lt; zx.werte[1] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[2] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[3] &lt;&lt; std::endl;<br />
std::cout &lt;&lt; zx.werte[4] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[5] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[6] &lt;&lt; std::endl;<br />
std::cout &lt;&lt; zx.werte[7] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[8] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[9] &lt;&lt; std::endl &lt;&lt; std::endl;<br />
}</p>
<p>Zum ausgeben der Werte des Stuct, und</p>
<p>void zustand_note_init(zustand_note zy, int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9)<br />
{<br />
zy.werte[1] = int1;<br />
zy.werte[2] = int2;<br />
zy.werte[3] = int3;<br />
zy.werte[4] = int4;<br />
zy.werte[5] = int5;<br />
zy.werte[6] = int6;<br />
zy.werte[7] = int7;<br />
zy.werte[8] = int8;<br />
zy.werte[9] = int9;<br />
}</p>
<p>zum initialisieren der werte. Jetzt mein Problem:<br />
int main(int argc, char *argv[])<br />
{<br />
zustand_note startzustand;<br />
zustand_note endzustand;</p>
<p>std::cout &lt;&lt; &quot;Programm 8-Puzzle-Breitensuche wird gestartet!\n&quot;;</p>
<p>zustand_note_init(startzustand, 2, 8, 3, 1, 6, 4, 7, 0, 5);<br />
zustand_note_ausgeben(startzustand); //erste Ausgabe</p>
<p>zustand_note *node = new zustand_note;<br />
node-&gt;werte = startzustand.werte;<br />
node-&gt;next = anker;<br />
zustand_note_ausgeben(node-&gt;werte);// zweite Ausgabe<br />
zustand_note_init(endzustand, 1, 2, 3, 8, 0, 4, 7, 6, 5);<br />
zustand_note_ausgeben(endzustand);// dritte Ausgabe<br />
zustand_note_ausgeben(startzustand);// vierteAusgabe<br />
zustand_note_ausgeben(node-&gt;werte);// fünfte Ausgabe</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
};</p>
<p>Ich initialisiere den Startzustand und kopiere seine Werte in den neuen Zeiger auf ein Structelement. danach initialisiere ich den endzustand.<br />
Jetzt kommt die Ausgabe:<br />
Programm 8-Puzzle-Breitensuche wird gestartet!<br />
2 8 3 //Ausgabe 1 alls richtig startzustand initialsiert und<br />
1 6 4 // werte richtig<br />
7 0 5</p>
<p>2 8 3 //Ausgabe 2 alls richtig *node initialsiert und werte richtig kopiert<br />
1 6 4<br />
7 0 5</p>
<p>1 2 3 //Ausgabe 3 alls richtig endzustand initialsiert und<br />
8 0 4 // werte richtig<br />
7 6 5</p>
<p>1 2 3 // erneute Ausgabe von startzustand gibt mir die werte des endzustand???<br />
8 0 4 // wie kann das sein, hab doch nichts geändert<br />
7 6 5</p>
<p>1 2 3 // erneute Ausgabe von *node gibt mir auch die werte des endzustand???<br />
8 0 4<br />
7 6 5</p>
<p>Drücken Sie eine beliebige Taste . . .</p>
<p>Kann mir das bitte iner erklären oder lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/211898/wer-kanns-erklären</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 12:28:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/211898.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Apr 2008 22:09:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wer kanns erklären?? on Mon, 28 Apr 2008 22:09:09 GMT]]></title><description><![CDATA[<p>Bin Neuling, vielleicht kann mit jemand folgendes erklären:<br />
Das ist mein Struct:</p>
<p>struct zustand_note<br />
{<br />
std::vector&lt;int&gt; werte; // die Zahlen in einen Vektor verpackt<br />
zustand_note *next; // Verknüpfung zum Nachfolger<br />
};<br />
zustand_note *anker = 0; // Anfang der Liste</p>
<p>ein Vektor zum Speichern von intWerten und ein Zeiger auf das nächste Element von Struct.<br />
2 Funktionen:<br />
void zustand_note_ausgeben(zustand_note zx)<br />
{<br />
std::cout &lt;&lt; zx.werte[1] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[2] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[3] &lt;&lt; std::endl;<br />
std::cout &lt;&lt; zx.werte[4] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[5] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[6] &lt;&lt; std::endl;<br />
std::cout &lt;&lt; zx.werte[7] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[8] &lt;&lt; &quot; &quot; &lt;&lt; zx.werte[9] &lt;&lt; std::endl &lt;&lt; std::endl;<br />
}</p>
<p>Zum ausgeben der Werte des Stuct, und</p>
<p>void zustand_note_init(zustand_note zy, int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9)<br />
{<br />
zy.werte[1] = int1;<br />
zy.werte[2] = int2;<br />
zy.werte[3] = int3;<br />
zy.werte[4] = int4;<br />
zy.werte[5] = int5;<br />
zy.werte[6] = int6;<br />
zy.werte[7] = int7;<br />
zy.werte[8] = int8;<br />
zy.werte[9] = int9;<br />
}</p>
<p>zum initialisieren der werte. Jetzt mein Problem:<br />
int main(int argc, char *argv[])<br />
{<br />
zustand_note startzustand;<br />
zustand_note endzustand;</p>
<p>std::cout &lt;&lt; &quot;Programm 8-Puzzle-Breitensuche wird gestartet!\n&quot;;</p>
<p>zustand_note_init(startzustand, 2, 8, 3, 1, 6, 4, 7, 0, 5);<br />
zustand_note_ausgeben(startzustand); //erste Ausgabe</p>
<p>zustand_note *node = new zustand_note;<br />
node-&gt;werte = startzustand.werte;<br />
node-&gt;next = anker;<br />
zustand_note_ausgeben(node-&gt;werte);// zweite Ausgabe<br />
zustand_note_init(endzustand, 1, 2, 3, 8, 0, 4, 7, 6, 5);<br />
zustand_note_ausgeben(endzustand);// dritte Ausgabe<br />
zustand_note_ausgeben(startzustand);// vierteAusgabe<br />
zustand_note_ausgeben(node-&gt;werte);// fünfte Ausgabe</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
};</p>
<p>Ich initialisiere den Startzustand und kopiere seine Werte in den neuen Zeiger auf ein Structelement. danach initialisiere ich den endzustand.<br />
Jetzt kommt die Ausgabe:<br />
Programm 8-Puzzle-Breitensuche wird gestartet!<br />
2 8 3 //Ausgabe 1 alls richtig startzustand initialsiert und<br />
1 6 4 // werte richtig<br />
7 0 5</p>
<p>2 8 3 //Ausgabe 2 alls richtig *node initialsiert und werte richtig kopiert<br />
1 6 4<br />
7 0 5</p>
<p>1 2 3 //Ausgabe 3 alls richtig endzustand initialsiert und<br />
8 0 4 // werte richtig<br />
7 6 5</p>
<p>1 2 3 // erneute Ausgabe von startzustand gibt mir die werte des endzustand???<br />
8 0 4 // wie kann das sein, hab doch nichts geändert<br />
7 6 5</p>
<p>1 2 3 // erneute Ausgabe von *node gibt mir auch die werte des endzustand???<br />
8 0 4<br />
7 6 5</p>
<p>Drücken Sie eine beliebige Taste . . .</p>
<p>Kann mir das bitte iner erklären oder lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1500124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1500124</guid><dc:creator><![CDATA[danhof]]></dc:creator><pubDate>Mon, 28 Apr 2008 22:09:09 GMT</pubDate></item><item><title><![CDATA[Reply to wer kanns erklären?? on Mon, 28 Apr 2008 22:35:28 GMT]]></title><description><![CDATA[<p>1. Benutze cpp - Tags.<br />
2. Ist dein Code so nicht annähernd lauffähig.<br />
- vector wird nicht initialisiert. -&gt; Überlauf<br />
- du greifst bei dem vector auf [9] zu, was bei 8 Elemente, wie du sie hast auch einen Fehler gibt.<br />
- Da du das Objekt als ganzes übergibst und keinen copy-ctor hast, crasht es auch da.<br />
3. Du übergibst beim füllen das Objekt per Kopie, was auch falsch ist.<br />
4. Du hast da kein delete für node</p>
<p>Ich frage mich überhaupt, wie du da eine Ausgabe bekommen hast.. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Nach meiner Anpassung bekomme ich die richtigen Ausgaben..Also behebe mal deine Fehler, dann funktionierts auch mit der Ausgabe. <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>Achja:<br />
Schrecklicher Code, aber das sollte mit der Zeit besser werden. (Darauf gehe ich jetzt nicht näher ein, ausser du bestehst darauf. ;))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1500130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1500130</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 28 Apr 2008 22:35:28 GMT</pubDate></item><item><title><![CDATA[Reply to wer kanns erklären?? on Tue, 29 Apr 2008 06:56:44 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>1. Benutze cpp - Tags.<br />
2. Ist dein Code so nicht annähernd lauffähig.<br />
- vector wird nicht initialisiert. -&gt; Überlauf<br />
- du greifst bei dem vector auf [9] zu, was bei 8 Elemente, wie du sie hast auch einen Fehler gibt.<br />
- Da du das Objekt als ganzes übergibst und keinen copy-ctor hast, crasht es auch da.<br />
3. Du übergibst beim füllen das Objekt per Kopie, was auch falsch ist.<br />
4. Du hast da kein delete für node<br />
...</p>
</blockquote>
<p>5. Der Threadtitel ist nichtssagend.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1500210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1500210</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 29 Apr 2008 06:56:44 GMT</pubDate></item><item><title><![CDATA[Reply to wer kanns erklären?? on Tue, 29 Apr 2008 10:07:48 GMT]]></title><description><![CDATA[<p>Simon2 schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>1. Benutze cpp - Tags.<br />
2. Ist dein Code so nicht annähernd lauffähig.<br />
- vector wird nicht initialisiert. -&gt; Überlauf<br />
- du greifst bei dem vector auf [9] zu, was bei 8 Elemente, wie du sie hast auch einen Fehler gibt.<br />
- Da du das Objekt als ganzes übergibst und keinen copy-ctor hast, crasht es auch da.<br />
3. Du übergibst beim füllen das Objekt per Kopie, was auch falsch ist.<br />
4. Du hast da kein delete für node<br />
...</p>
</blockquote>
<p>5. Der Threadtitel ist nichtssagend.</p>
</blockquote>
<p>Och.. Da gibts noch mehr.<br />
Allerdings muss ich da mal sagen, dass er da nicht der einzige ist,der einen nichtssagenden Titel hat... <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/1500350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1500350</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 29 Apr 2008 10:07:48 GMT</pubDate></item></channel></rss>