<?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[Schleife?]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>Ich schreibe gerade Tetris um mal zu gucken wie die Array Feld[x][y] sich verhält<br />
bis jetzt klappt alles ganz gut außer das hier:</p>
<pre><code>for(y=2;y&lt;=19;y++)
     {
      if(
      feld [2][y]==4 &amp;&amp; 
      feld [3][y]==4 &amp;&amp; 
      feld [4][y]==4 &amp;&amp; 
      feld [5][y]==4 &amp;&amp; 
      feld [6][y]==4 &amp;&amp; 
      feld [7][y]==4 &amp;&amp; 
      feld [8][y]==4 &amp;&amp; 
      feld [9][y]==4 &amp;&amp; 
      feld [10][y]==4 &amp;&amp; 
      feld [11][y]==4 &amp;&amp; 
      feld [12][y]==4 &amp;&amp; 
      feld [13][y]==4 &amp;&amp; 
      feld [14][y]==4 &amp;&amp; 
      feld [15][y]==4 &amp;&amp; 
      feld [16][y]==4 &amp;&amp; 
      feld [17][y]==4 &amp;&amp; 
      feld [18][y]==4 &amp;&amp; 
      feld [19][y]==4)
       { 
         score++;                
         for(x=2;x&lt;=19;x++)
           {
             feld[x][y]=1;
           }
      }
     }
</code></pre>
<p>Er schaut ob in meinem Spielfeld x&gt;2 bis x&lt;19 alle felder ==4 sind (4 heist einfach nur belegt) wenn das der Fall ist setzt er einen Punkt (score) hoch und setzt das Feld auf 'Leer'(==1)</p>
<p>in der untersten Reihe funktioniert das super nur in sonst keiner weiteren <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="😕"
    /></p>
<p>mfg<br />
Megawurrrm</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/302859/schleife</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 03:12:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/302859.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 29 Apr 2012 11:00:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 11:00:17 GMT]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>Ich schreibe gerade Tetris um mal zu gucken wie die Array Feld[x][y] sich verhält<br />
bis jetzt klappt alles ganz gut außer das hier:</p>
<pre><code>for(y=2;y&lt;=19;y++)
     {
      if(
      feld [2][y]==4 &amp;&amp; 
      feld [3][y]==4 &amp;&amp; 
      feld [4][y]==4 &amp;&amp; 
      feld [5][y]==4 &amp;&amp; 
      feld [6][y]==4 &amp;&amp; 
      feld [7][y]==4 &amp;&amp; 
      feld [8][y]==4 &amp;&amp; 
      feld [9][y]==4 &amp;&amp; 
      feld [10][y]==4 &amp;&amp; 
      feld [11][y]==4 &amp;&amp; 
      feld [12][y]==4 &amp;&amp; 
      feld [13][y]==4 &amp;&amp; 
      feld [14][y]==4 &amp;&amp; 
      feld [15][y]==4 &amp;&amp; 
      feld [16][y]==4 &amp;&amp; 
      feld [17][y]==4 &amp;&amp; 
      feld [18][y]==4 &amp;&amp; 
      feld [19][y]==4)
       { 
         score++;                
         for(x=2;x&lt;=19;x++)
           {
             feld[x][y]=1;
           }
      }
     }
</code></pre>
<p>Er schaut ob in meinem Spielfeld x&gt;2 bis x&lt;19 alle felder ==4 sind (4 heist einfach nur belegt) wenn das der Fall ist setzt er einen Punkt (score) hoch und setzt das Feld auf 'Leer'(==1)</p>
<p>in der untersten Reihe funktioniert das super nur in sonst keiner weiteren <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="😕"
    /></p>
<p>mfg<br />
Megawurrrm</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2206603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206603</guid><dc:creator><![CDATA[Megawurrrm]]></dc:creator><pubDate>Sun, 29 Apr 2012 11:00:17 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 11:37:02 GMT]]></title><description><![CDATA[<p>Hm anhand dieses Codestücks kann ich das nicht sagen. Es sieht aber danach aus dass du über die Arraygrenzen hinausgehst:</p>
<blockquote>
<p>Spielfeld x&gt;2 bis x&lt;19</p>
</blockquote>
<p>aber</p>
<pre><code>for(x=2;x&lt;=19;x++)
</code></pre>
<p>Und diese große if-Abfrage würde ich auch mit ner Schleife vereinfachen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2206610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206610</guid><dc:creator><![CDATA[DarkShadow44]]></dc:creator><pubDate>Sun, 29 Apr 2012 11:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 11:48:57 GMT]]></title><description><![CDATA[<p>die Grenze ist 20</p>
<p>ja das mit der Schlreife ist noch so ein Problem <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>
<p>ziemlich knifflieger fehler^^</p>
<pre><code>#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;conio2.h&gt;
#include &lt;windows.h&gt;

using namespace std;
int feld[20][20];
int x=1;
int y=1;
int stein_x=10;
int stein_y=2;
char tastendruck;
int score=1;
int x2=19;
int y2=19;

void null_setzen()
  {
    for(x=1;x&lt;=20;x++)
    {
      for(y=1;y&lt;=20;y++)
      {
        feld[x][y]=1;
      }
    }
  }
void spielfeld()
  {
    for (x=1;x&lt;=20;x++)
    {
        feld[x][1]=2;
        feld[x][20]=2;
    }
    for (y=1;y&lt;=20;y++)
    {
        feld[1][y]=3;
        feld[20][y]=3;
    }
  }
void darstellen()
  {
    gotoxy(40,10);
    cprintf(&quot;score: %i &quot;,score);
    gotoxy(40,11);
    cprintf(&quot;stein_x: %i &quot;,stein_x);
    gotoxy(40,12);
    cprintf(&quot;stein_y: %i &quot;,stein_y);
    for(x=1;x&lt;=20;x++)
    {
      for(y=1;y&lt;=20;y++)
      {
        gotoxy(x,y);
        if (feld[x][y]==1)
          {
            cprintf(&quot; &quot;);
          }
        if (feld[x][y]==2)
          {
            cprintf(&quot;-&quot;);
          }
        if (feld[x][y]==3)
          {
            cprintf(&quot;|&quot;);
          }
        if (feld[x][y]==4)
          {
            cprintf(&quot;#&quot;);
          }
      }
    }
  }
void reihe()
  {
    for(y=2;y&lt;=19;y++)
     {
      if(
      feld [2][y]==4 &amp;&amp; 
      feld [3][y]==4 &amp;&amp; 
      feld [4][y]==4 &amp;&amp; 
      feld [5][y]==4 &amp;&amp; 
      feld [6][y]==4 &amp;&amp; 
      feld [7][y]==4 &amp;&amp; 
      feld [8][y]==4 &amp;&amp; 
      feld [9][y]==4 &amp;&amp; 
      feld [10][y]==4 &amp;&amp; 
      feld [11][y]==4 &amp;&amp; 
      feld [12][y]==4 &amp;&amp; 
      feld [13][y]==4 &amp;&amp; 
      feld [14][y]==4 &amp;&amp; 
      feld [15][y]==4 &amp;&amp; 
      feld [16][y]==4 &amp;&amp; 
      feld [17][y]==4 &amp;&amp; 
      feld [18][y]==4 &amp;&amp; 
      feld [19][y]==4)
       { 
         score++;                
         for(x=2;x&lt;=19;x++)
           {
             feld[x][stein_y]=1;
           }
      }
     }
  }
void stein1()
  {
    stein_x=10;
    stein_y=3;
    while(stein_y!=19)
      {
       if(feld[stein_x][stein_y+1]==1 || feld[stein_x][stein_y+1]==2)
        {
         feld[stein_x][stein_y]=1;
         stein_y++;
         feld[stein_x][stein_y]=4;
         darstellen();
         if(kbhit() &amp;&amp; stein_y&lt;19  )
           {
             tastendruck=getch();
             switch(tastendruck)
               {
                  case'a':
                          feld[stein_x][stein_y]=1;
                          stein_x--;
                          if (stein_x&lt;=1)
                            {
                              stein_x++;
                            }
                       break;
                  case'd':
                          feld[stein_x][stein_y]=1;
                          stein_x++;
                          if (stein_x&gt;=20)
                            {
                              stein_x--;
                            }
                       break;
                  case 'c':
                        for(x2=2;x2&lt;=18;x2++)
                          {
                             feld[x2][y2]=4;
                          }
                          y2--;
                       break;
                  default:
                          while(tastendruck != 'a' &amp;&amp; tastendruck != 'd')
                            {
                               gotoxy(8,10);
                               cprintf(&quot;&lt;&lt;Pause&gt;&gt;&quot;);
                               tastendruck=getch();
                            }
                       break;
               }
           }
         Sleep(50);
        }
       else
        {
          stein_x=10;
          stein_y=3;
        }
      }
  }

int main(int argc, char *argv[])
{
  null_setzen();
  spielfeld();
  int x2=5;
  while(x2==5)
    {
      stein1(); 
      reihe();
    }
    getch();
    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2206614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206614</guid><dc:creator><![CDATA[Megawurrrm]]></dc:creator><pubDate>Sun, 29 Apr 2012 11:48:57 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 12:41:36 GMT]]></title><description><![CDATA[<p>Bei einem Array mit 20 Elementen dürfen die Indexe von 0 bis 19 laufen. Und die Laufvariable einer for-Schleife global zu definieren ist auch eine ziemlich dumme Idee!</p>
<pre><code class="language-cpp">for( int x = 0; x &lt; 20; ++x)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2206621</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206621</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 29 Apr 2012 12:41:36 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 13:04:46 GMT]]></title><description><![CDATA[<p>k habe die array auf 25 gesetzt da tut sich aber nichts<br />
- bei einer lokalen difinition verändert sich auch nichts <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="😕"
    /></p>
<p>habt ihr vielleicht eine idee wie ich alternativ die reihen überprüfen könnte?<br />
dan kann ich mir dieses Gravurstück vielleicht sparen ^^</p>
<p>danke für die hilfe <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/2206625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206625</guid><dc:creator><![CDATA[Megawurrrm]]></dc:creator><pubDate>Sun, 29 Apr 2012 13:04:46 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 13:17:01 GMT]]></title><description><![CDATA[<p>Alter, ersetz mal die riesige if abfrage durch eine Funktion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2206628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206628</guid><dc:creator><![CDATA[Namenloser324]]></dc:creator><pubDate>Sun, 29 Apr 2012 13:17:01 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 13:27:10 GMT]]></title><description><![CDATA[<p>gerne welche funktion ? <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/2206633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206633</guid><dc:creator><![CDATA[Megawurrrm]]></dc:creator><pubDate>Sun, 29 Apr 2012 13:27:10 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 13:41:40 GMT]]></title><description><![CDATA[<p>Eine selbst geschriebene.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2206639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206639</guid><dc:creator><![CDATA[Namenloser324]]></dc:creator><pubDate>Sun, 29 Apr 2012 13:41:40 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife? on Sun, 29 Apr 2012 14:11:44 GMT]]></title><description><![CDATA[<p>davon mal abgesehen weiß ich leider noch nciht wirklich wo das problem mit den reihen ist</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2206648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2206648</guid><dc:creator><![CDATA[Megawurrrm]]></dc:creator><pubDate>Sun, 29 Apr 2012 14:11:44 GMT</pubDate></item></channel></rss>