<?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[Problem]]></title><description><![CDATA[<p>Hallo zusammen<br />
Ein guter Freund von mir Programmiert auch C++, da aber sein Internet im Moment nicht geht, poste ich das für ihn..</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

using namespace std;

void start ();
void dungeon ();

int j, life, lifeenemy, h, hm, w, wm, s, r, jm, hs, d, a, ls, ks;
char  c;

void
start ()

{
       life = 100; // Leben
       lifeenemy = 0; // Leben des Feindes
       j = 0; // Was sich in der Dungeon befindet
       jm = 200; // Der höchste Dungeon-level
       h = 0; // Wieviel ein Feind schaden machen kann
       hm = 0; // Wieviel ein Feind höchstens schaden machen kann
       w = 0; // Wieviel die Waffe schaden machen kann
       wm = 0; // Wieviel die Waffe höchstens schaden machen kann
       s = 1; // Stufe
       r = 0; // Raum
       //Objekte:
       hs = 0; // Holzstock
       d = 0; // Dolch
       a = 0; // Axt
       ls = 0; // Langschwert
       ks = 0; // Kurzschwert

       cout &lt;&lt; &quot;Du befindest dich in einem laenglichen Raum.\n&quot;; 
       cout &lt;&lt; &quot;An der Wand befindet sich eine Tuer (1).\n&quot;;
       cout &lt;&lt; &quot;Vor dir liegt ein Holzstock (2).\n&quot;;
       cout &lt;&lt; &quot;......(1)......\n&quot;;
       cout &lt;&lt; &quot;.     (2)     .\n&quot;;
       cout &lt;&lt; &quot;.      X      .\n&quot;;
       cout &lt;&lt; &quot;...............\n&quot;;
       c = 30;
       cin &gt;&gt; c;
       switch (c)
       {
              case '1' : r = 1;
              break;
              case '2' : hs = 1, d = 0, a = 0, ls = 0, ks = 0; 
              break;
              case '0' : exit(0);
              break;
       }
       if (r == 1)
       {
             cout &lt;&lt; &quot;Nimm dir lieber den Stock als Waffe, bevor du den naechsten Raum betrittst!\n&quot;;
             start ();
       }
       if (hs == 1)
       {

              cout &lt;&lt; &quot;Du befindest dich in einem laenglichen Raum.\n&quot;; 
              cout &lt;&lt; &quot;An der Wand befindet sich eine Tuer (1).\n&quot;;
              cout &lt;&lt; &quot;......(1)......\n&quot;;
              cout &lt;&lt; &quot;.      X      .\n&quot;;
              cout &lt;&lt; &quot;.             .\n&quot;;
              cout &lt;&lt; &quot;...............\n&quot;;
              c = 30;
              cin &gt;&gt; c;
              switch (c)
              {

                     case '1' : r = 2;
                     break;
                     case '0' : exit(0);
                     break;
              }
       }
       if (r = 2)
       {

             srand( (unsigned)time( NULL ) );
             j = rand() % jm;

             srand( (unsigned)time( NULL ) );
             w = rand() % wm;
             dungeon ();
       }
}

void
dungeon ()
{     
     srand( (unsigned)time( NULL ) );
     h = rand() % hm;

     if (hs == 1)
     {
          wm = 2;
     }
     else if (d == 1)
     {
          wm = 3;
     }
     else if (a == 1)
     {
          wm = 12;
     }
     else if (ls == 1)
     {
          wm = 10;
     }
     else if (ks == 1)
     {
          wm = 8;
     }
     if (r == 2)
     {
          jm = 2;
          if (j == 1)
          { 
                cout &lt;&lt; &quot;Als du den Raum betrittst, greift dich eine Ratte (Stufe 1) an.\n&quot;;
                lifeenemy = 10;
                hm = 1;
                cout &lt;&lt; &quot;Du schlaegst mit deiner Waffe auf die Ratte ein. &quot; &lt;&lt; w &lt;&lt; &quot; Schaden für die Ratte.\n&quot;;
          }

     }
}

int main()
{
    cout &lt;&lt; &quot;Ugh.\n&quot;;

    start ();
    return 0;
}
</code></pre>
<p>(Er hat das Programm noch nicht fertig...)<br />
Wenn er das &quot;Compiliert&quot; gibt es einen typischen Windows Fehler. (Senden, nicht Senden) Kann mir jemand sagen, was er falsch gemacht hat?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/148417/problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 19:40:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/148417.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 May 2006 13:12:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem on Fri, 26 May 2006 13:12:27 GMT]]></title><description><![CDATA[<p>Hallo zusammen<br />
Ein guter Freund von mir Programmiert auch C++, da aber sein Internet im Moment nicht geht, poste ich das für ihn..</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

using namespace std;

void start ();
void dungeon ();

int j, life, lifeenemy, h, hm, w, wm, s, r, jm, hs, d, a, ls, ks;
char  c;

void
start ()

{
       life = 100; // Leben
       lifeenemy = 0; // Leben des Feindes
       j = 0; // Was sich in der Dungeon befindet
       jm = 200; // Der höchste Dungeon-level
       h = 0; // Wieviel ein Feind schaden machen kann
       hm = 0; // Wieviel ein Feind höchstens schaden machen kann
       w = 0; // Wieviel die Waffe schaden machen kann
       wm = 0; // Wieviel die Waffe höchstens schaden machen kann
       s = 1; // Stufe
       r = 0; // Raum
       //Objekte:
       hs = 0; // Holzstock
       d = 0; // Dolch
       a = 0; // Axt
       ls = 0; // Langschwert
       ks = 0; // Kurzschwert

       cout &lt;&lt; &quot;Du befindest dich in einem laenglichen Raum.\n&quot;; 
       cout &lt;&lt; &quot;An der Wand befindet sich eine Tuer (1).\n&quot;;
       cout &lt;&lt; &quot;Vor dir liegt ein Holzstock (2).\n&quot;;
       cout &lt;&lt; &quot;......(1)......\n&quot;;
       cout &lt;&lt; &quot;.     (2)     .\n&quot;;
       cout &lt;&lt; &quot;.      X      .\n&quot;;
       cout &lt;&lt; &quot;...............\n&quot;;
       c = 30;
       cin &gt;&gt; c;
       switch (c)
       {
              case '1' : r = 1;
              break;
              case '2' : hs = 1, d = 0, a = 0, ls = 0, ks = 0; 
              break;
              case '0' : exit(0);
              break;
       }
       if (r == 1)
       {
             cout &lt;&lt; &quot;Nimm dir lieber den Stock als Waffe, bevor du den naechsten Raum betrittst!\n&quot;;
             start ();
       }
       if (hs == 1)
       {

              cout &lt;&lt; &quot;Du befindest dich in einem laenglichen Raum.\n&quot;; 
              cout &lt;&lt; &quot;An der Wand befindet sich eine Tuer (1).\n&quot;;
              cout &lt;&lt; &quot;......(1)......\n&quot;;
              cout &lt;&lt; &quot;.      X      .\n&quot;;
              cout &lt;&lt; &quot;.             .\n&quot;;
              cout &lt;&lt; &quot;...............\n&quot;;
              c = 30;
              cin &gt;&gt; c;
              switch (c)
              {

                     case '1' : r = 2;
                     break;
                     case '0' : exit(0);
                     break;
              }
       }
       if (r = 2)
       {

             srand( (unsigned)time( NULL ) );
             j = rand() % jm;

             srand( (unsigned)time( NULL ) );
             w = rand() % wm;
             dungeon ();
       }
}

void
dungeon ()
{     
     srand( (unsigned)time( NULL ) );
     h = rand() % hm;

     if (hs == 1)
     {
          wm = 2;
     }
     else if (d == 1)
     {
          wm = 3;
     }
     else if (a == 1)
     {
          wm = 12;
     }
     else if (ls == 1)
     {
          wm = 10;
     }
     else if (ks == 1)
     {
          wm = 8;
     }
     if (r == 2)
     {
          jm = 2;
          if (j == 1)
          { 
                cout &lt;&lt; &quot;Als du den Raum betrittst, greift dich eine Ratte (Stufe 1) an.\n&quot;;
                lifeenemy = 10;
                hm = 1;
                cout &lt;&lt; &quot;Du schlaegst mit deiner Waffe auf die Ratte ein. &quot; &lt;&lt; w &lt;&lt; &quot; Schaden für die Ratte.\n&quot;;
          }

     }
}

int main()
{
    cout &lt;&lt; &quot;Ugh.\n&quot;;

    start ();
    return 0;
}
</code></pre>
<p>(Er hat das Programm noch nicht fertig...)<br />
Wenn er das &quot;Compiliert&quot; gibt es einen typischen Windows Fehler. (Senden, nicht Senden) Kann mir jemand sagen, was er falsch gemacht hat?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1065502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1065502</guid><dc:creator><![CDATA[Muzklash]]></dc:creator><pubDate>Fri, 26 May 2006 13:12:27 GMT</pubDate></item><item><title><![CDATA[Reply to Problem on Fri, 26 May 2006 13:23:14 GMT]]></title><description><![CDATA[<p>Am besten jagt er das Ding einfach mal durch den Debugger! Das geht auch ohne Internet!</p>
<p>grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1065513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1065513</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Fri, 26 May 2006 13:23:14 GMT</pubDate></item><item><title><![CDATA[Reply to Problem on Fri, 26 May 2006 13:25:05 GMT]]></title><description><![CDATA[<p>für wm und hm sollte man einen anderen Wert als 0 einsetzen, da eine Division durch 0 nicht möglich ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1065514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1065514</guid><dc:creator><![CDATA[Jens_König]]></dc:creator><pubDate>Fri, 26 May 2006 13:25:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem on Fri, 26 May 2006 13:53:20 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if (r == 1)
       {
             cout &lt;&lt; &quot;Nimm dir lieber den Stock als Waffe, bevor du den naechsten Raum betrittst!\n&quot;;
             start ();
       }
</code></pre>
<p>Ich denke, dein Freund will, dass nach <em>start()</em> die funktion abgebrochen wird. Denn wenn <em>start()</em> aufgerufen wird, dann beginnt das Spiel quasi wieder von vorne, aber wenn alle Funktionen abgearbeitet sind (also, das Spiel beendet wird), dann springt das Programm wieder an diese Stelle zurück und führt den Code weiter aus.<br />
So könnte man das leicht verhindern:</p>
<pre><code class="language-cpp">if (r == 1)
       {
             cout &lt;&lt; &quot;Nimm dir lieber den Stock als Waffe, bevor du den naechsten Raum betrittst!\n&quot;;
             start ();
            return ;
       }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1065531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1065531</guid><dc:creator><![CDATA[SomeBody]]></dc:creator><pubDate>Fri, 26 May 2006 13:53:20 GMT</pubDate></item></channel></rss>