<?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[I dont understand the code]]></title><description><![CDATA[<p>das ist die Aufgabe: <a href="http://puu.sh/jLEQI/0eb5a4f88c.jpg" rel="nofollow">http://puu.sh/jLEQI/0eb5a4f88c.jpg</a><br />
naja ich kam dort nicht weiter und hab mir die lösung aus dem internet geholt,</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main()
{
    // Read init information from standard input, if any
    int r,l,g;
    cin&gt;&gt;r;         //length of platform
    cin&gt;&gt;g;         //lenth of the gap
    cin&gt;&gt;l;         //length of Landing platform
    int d,crit;

    int s,x;
    while (1) {

        cin&gt;&gt;s;         //Current Speed
        cin&gt;&gt;x;         //Current position
        d=r-x;  

        //incase if you are already on high speed
        crit=0;
        for(int i=0;i&lt;s;i++)
        {
            crit+=i;
        }

        //inorder to avoid divide by zero exception
        if(s==0)
        {
            cout&lt;&lt;&quot;SPEED&quot;&lt;&lt;endl;
        }

        else
        if(x&gt;=r)        //Slow down the speed incase 1st platform is crossed
        {
            cout&lt;&lt;&quot;SLOW&quot;&lt;&lt;endl;    
        }

        else
        if(s&gt;=g+d)          //Jump incase speed is enough to cover the remaining distance+gap      
        {
            cout&lt;&lt;&quot;JUMP&quot;&lt;&lt;endl;
        }

        else
        if(crit&gt;=l)     //if speed is greater than the minnimum speed required to stop at next platform     
        {
            cout&lt;&lt;&quot;SLOW&quot;&lt;&lt;endl;
        }

        //The main logic for increasing speed 
        else
        if(((d%s)+g)&gt;s) 
        {
            cout &lt;&lt; &quot;SPEED&quot; &lt;&lt; endl;

        }

        else
        if((d-1)/s==0)
        {
            if((d-1)%s!=0)
            {
                cout&lt;&lt;&quot;SLOW&quot;&lt;&lt;endl;
            }
        }

        else
        {

            cout&lt;&lt;&quot;WAIT&quot;&lt;&lt;endl;
        }

        }

    return 0;

}
</code></pre>
<p>ich versteh den code nicht und woher das programm weiß was das für eine variable ist, die sehen mir einfach random zugeordnet aus z.B r=length of platform woher weiß das programm das? oder was macht das hier z.b d=r-x;</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/334117/i-dont-understand-the-code</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 00:59:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/334117.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Aug 2015 15:39:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 15:39:04 GMT]]></title><description><![CDATA[<p>das ist die Aufgabe: <a href="http://puu.sh/jLEQI/0eb5a4f88c.jpg" rel="nofollow">http://puu.sh/jLEQI/0eb5a4f88c.jpg</a><br />
naja ich kam dort nicht weiter und hab mir die lösung aus dem internet geholt,</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main()
{
    // Read init information from standard input, if any
    int r,l,g;
    cin&gt;&gt;r;         //length of platform
    cin&gt;&gt;g;         //lenth of the gap
    cin&gt;&gt;l;         //length of Landing platform
    int d,crit;

    int s,x;
    while (1) {

        cin&gt;&gt;s;         //Current Speed
        cin&gt;&gt;x;         //Current position
        d=r-x;  

        //incase if you are already on high speed
        crit=0;
        for(int i=0;i&lt;s;i++)
        {
            crit+=i;
        }

        //inorder to avoid divide by zero exception
        if(s==0)
        {
            cout&lt;&lt;&quot;SPEED&quot;&lt;&lt;endl;
        }

        else
        if(x&gt;=r)        //Slow down the speed incase 1st platform is crossed
        {
            cout&lt;&lt;&quot;SLOW&quot;&lt;&lt;endl;    
        }

        else
        if(s&gt;=g+d)          //Jump incase speed is enough to cover the remaining distance+gap      
        {
            cout&lt;&lt;&quot;JUMP&quot;&lt;&lt;endl;
        }

        else
        if(crit&gt;=l)     //if speed is greater than the minnimum speed required to stop at next platform     
        {
            cout&lt;&lt;&quot;SLOW&quot;&lt;&lt;endl;
        }

        //The main logic for increasing speed 
        else
        if(((d%s)+g)&gt;s) 
        {
            cout &lt;&lt; &quot;SPEED&quot; &lt;&lt; endl;

        }

        else
        if((d-1)/s==0)
        {
            if((d-1)%s!=0)
            {
                cout&lt;&lt;&quot;SLOW&quot;&lt;&lt;endl;
            }
        }

        else
        {

            cout&lt;&lt;&quot;WAIT&quot;&lt;&lt;endl;
        }

        }

    return 0;

}
</code></pre>
<p>ich versteh den code nicht und woher das programm weiß was das für eine variable ist, die sehen mir einfach random zugeordnet aus z.B r=length of platform woher weiß das programm das? oder was macht das hier z.b d=r-x;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465216</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465216</guid><dc:creator><![CDATA[C++Nab]]></dc:creator><pubDate>Sun, 23 Aug 2015 15:39:04 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 16:51:21 GMT]]></title><description><![CDATA[<p>Lese nach wozu &quot;cin&quot; und &quot;cout&quot; gut sind, auch wie &quot;while&quot;, &quot;for ...&quot; und &quot;if...else&quot; funktionieren, dann kommst du dahinter <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/2465225</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465225</guid><dc:creator><![CDATA[deejey]]></dc:creator><pubDate>Sun, 23 Aug 2015 16:51:21 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 17:05:28 GMT]]></title><description><![CDATA[<p>cin = c input<br />
cout = c output<br />
for = schleife syntax for(int x = 0; x operator z;x++ oder x-- --x usw)<br />
if = bedingung<br />
while = schleife die läuft bis die bedingung nicht mehr stimmt und es einen break gibt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465231</guid><dc:creator><![CDATA[C++Nab]]></dc:creator><pubDate>Sun, 23 Aug 2015 17:05:28 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 17:10:01 GMT]]></title><description><![CDATA[<p>C++Nab schrieb:</p>
<blockquote>
<p>cin = c input<br />
cout = c output<br />
for = schleife syntax for(int x = 0; x operator z;x++ oder x-- --x usw)<br />
if = bedingung<br />
while = schleife die läuft bis die bedingung nicht mehr stimmt und es einen break gibt</p>
</blockquote>
<p>ok, du hattest ja geschrieben &quot;<em>die sehen mir einfach random zugeordnet aus z.B r=length of platform woher weiß das programm das?</em>&quot; - mit dem Wissen müsstest du jetzt erkennen können, woher das Programm &quot;r=length&quot; kennt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465232</guid><dc:creator><![CDATA[deejey]]></dc:creator><pubDate>Sun, 23 Aug 2015 17:10:01 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 18:59:59 GMT]]></title><description><![CDATA[<p>Mache Dir den logischen Aufbaue deines Programms bewusst. Zeichne am besten ein Flussdiagramm.</p>
<pre><code>int main()
{
    //...

    while (true) // Dauerschleife 
    {
        //...

        for(int i=0;i&lt;s;i++)
        {
            //...
        }

        if(...)
        {
            //...
        }
        else if(...)
        {
            //...
        }       
        else if(...)
        {
            //...
        }       
        else if(...)
        {
            //...
        }
        else if(...)
        {
            //...   
        }
        else if(...)
        {
            if(...)
            {
                //...
            }
        }
        else
        {           
            //...
        }
    }// end of while

    return 0; // Kläre die Frage: Kommst Du hier überhaupt hin? Wenn ja, wie?
}
</code></pre>
<p><a href="http://www.tutorialspoint.com/cprogramming/c_decision_making.htm" rel="nofollow">http://www.tutorialspoint.com/cprogramming/c_decision_making.htm</a><br />
<a href="http://www.tutorialspoint.com/cprogramming/c_loops.htm" rel="nofollow">http://www.tutorialspoint.com/cprogramming/c_loops.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465249</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465249</guid><dc:creator><![CDATA[Erhard Henkes]]></dc:creator><pubDate>Sun, 23 Aug 2015 18:59:59 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 19:16:10 GMT]]></title><description><![CDATA[<p>Erhard Henkes schrieb:</p>
<blockquote>
<p>Zeichne am besten ein Flussdiagramm.</p>
</blockquote>
<p>lol</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465251</guid><dc:creator><![CDATA[flusspferd]]></dc:creator><pubDate>Sun, 23 Aug 2015 19:16:10 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 19:52:17 GMT]]></title><description><![CDATA[<p>Na, immerhin sieben if/(else). Eine while-loop ohne Ausgang. Da lohnt es sich bestimmt über den Aufbau und auch zeitlichen Ablauf (z.B. Reihenfolge der if/else) nachzudenken. Grafisch geht das zumeist anschaulicher, auch wenn das hier für einen geübten Progger einfach zu überblicken ist. <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>Dies hier sollte z.B. hinterfragt werden:</p>
<pre><code>else if(...)
{
    if(...)
    {
        //...
    }
}
</code></pre>
<p>Hier sollte man ein if einsparen können.</p>
<p>Ein Ausbruch aus der while-loop mittels break könnte Sinn machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465252</guid><dc:creator><![CDATA[Erhard Henkes]]></dc:creator><pubDate>Sun, 23 Aug 2015 19:52:17 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Sun, 23 Aug 2015 21:21:51 GMT]]></title><description><![CDATA[<p>Naja, das ist sozusagen die Game-Loop, nur das der Spieler in dem Fall dein Programm ist. Der Benutzer gibt die Parameter ein und dein Programm soll versuchen, das Problem zu lösen.</p>
<p>Was ich bei deinem Beispielprogramm nicht verstehe, ist wie die Win-Condition oder der Failure-State bestimmt wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465270</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465270</guid><dc:creator><![CDATA[IrgendeinName]]></dc:creator><pubDate>Sun, 23 Aug 2015 21:21:51 GMT</pubDate></item><item><title><![CDATA[Reply to I dont understand the code on Mon, 24 Aug 2015 09:26:13 GMT]]></title><description><![CDATA[<p>C++Nab schrieb:</p>
<blockquote>
<p>das ist die Aufgabe: <a href="http://puu.sh/jLEQI/0eb5a4f88c.jpg" rel="nofollow">http://puu.sh/jLEQI/0eb5a4f88c.jpg</a><br />
naja ich kam dort nicht weiter und hab mir die lösung aus dem internet geholt,</p>
</blockquote>
<p>Du hast Dir <em>eine</em> Lösung aus dem Internet geholt. Und eine sehr bescheidene noch dazu.<br />
Das ist IMHO nicht gut für Anfänger.</p>
<p>Off-topic:<br />
Woran liegt es nur, dass <a href="https://www.codingame.com/start" rel="nofollow">codingame.com</a> hier gerade so populär ist? (in diesem Fall das Puzzle &quot;Skynet: the Chasm&quot;)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465320</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465320</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Mon, 24 Aug 2015 09:26:13 GMT</pubDate></item></channel></rss>