<?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[Roulett-problem]]></title><description><![CDATA[<p>Hallo<br />
ich möchte ein Roulettprogramm schreiben und habe mir das wichtigste schonmal programmiert aber es gibt einige Probleme und ich weiß nicht woran das liegt.</p>
<p>Nachdem: &quot;Wie oft wollen sie setzen?&quot; ausgegeben wird gebe ich eine Zahl ein, aber egal welche, nachdem ich z oder g eingegeben habe erscheint &quot;50&quot; und dann erneut die Frage &quot;Wie oft wollen sie setzen?&quot; Ich habe also keine Möglichkeit einen Betrag auf eine Zahl zu setzen.</p>
<p>Ich bitte dringend um Hilfe, hier der Quellcode:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class roulett
{
      public:
             int geld, einsatz, zahl, tipp ;
             void vzahl();
             void vgerade();
};

void roulett::vzahl(void)
{
     cin &gt;&gt; tipp ;
     cin &gt;&gt; einsatz ;
     if( tipp == zahl )
     {
         geld = geld + einsatz * 35 ;
     }
     else
     {
         geld = geld - einsatz ;
     }
}

void roulett::vgerade(void)
{
     cout &lt;&lt; &quot;\n1 fuer ungrade zahl, 2 fuer grade\n&quot; ;
     cin &gt;&gt; tipp ;
     cin &gt;&gt; einsatz ;

     if( tipp % 2 == zahl % 2 ) 
     {
         geld += einsatz * 2 ;
     }else{
         geld -= einsatz ;
     }

     if( tipp % 2 == zahl % 2 )
     {
         geld += einsatz * 2 ;
     }else{
         geld -= einsatz ;
     }
}

int main()
{
    int x, n ;
    char wahl ;
    roulett test ;

    test.geld = 50 ;

    srand((unsigned) time(NULL));

    for(;;)
    {

       /*   Zahl generieren    */
       test.zahl=rand()%37;

       cout &lt;&lt; &quot;\nWie oft wollen sie setzen?\n&quot; ;
       cin &gt;&gt; x ;
       cout &lt;&lt; &quot;&lt;z&gt; auf Zahl tippen\n&lt;g&gt; auf grade oder ungrade tippen&quot; ;
       cin &gt;&gt; wahl ; 

       for(n=0;n&gt;x;n++)
       {
                 if( wahl == 'z' || wahl == 'Z' )
                 {
                     test.vzahl();
                 }
                 else
                 {
                     test.vgerade();
                 }       
       }

       cout &lt;&lt; test.geld ;     

    }      

    return 0;
}
</code></pre>
<p>Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/134417/roulett-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 12:27:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/134417.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jan 2006 20:12:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Roulett-problem on Wed, 25 Jan 2006 20:12:30 GMT]]></title><description><![CDATA[<p>Hallo<br />
ich möchte ein Roulettprogramm schreiben und habe mir das wichtigste schonmal programmiert aber es gibt einige Probleme und ich weiß nicht woran das liegt.</p>
<p>Nachdem: &quot;Wie oft wollen sie setzen?&quot; ausgegeben wird gebe ich eine Zahl ein, aber egal welche, nachdem ich z oder g eingegeben habe erscheint &quot;50&quot; und dann erneut die Frage &quot;Wie oft wollen sie setzen?&quot; Ich habe also keine Möglichkeit einen Betrag auf eine Zahl zu setzen.</p>
<p>Ich bitte dringend um Hilfe, hier der Quellcode:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class roulett
{
      public:
             int geld, einsatz, zahl, tipp ;
             void vzahl();
             void vgerade();
};

void roulett::vzahl(void)
{
     cin &gt;&gt; tipp ;
     cin &gt;&gt; einsatz ;
     if( tipp == zahl )
     {
         geld = geld + einsatz * 35 ;
     }
     else
     {
         geld = geld - einsatz ;
     }
}

void roulett::vgerade(void)
{
     cout &lt;&lt; &quot;\n1 fuer ungrade zahl, 2 fuer grade\n&quot; ;
     cin &gt;&gt; tipp ;
     cin &gt;&gt; einsatz ;

     if( tipp % 2 == zahl % 2 ) 
     {
         geld += einsatz * 2 ;
     }else{
         geld -= einsatz ;
     }

     if( tipp % 2 == zahl % 2 )
     {
         geld += einsatz * 2 ;
     }else{
         geld -= einsatz ;
     }
}

int main()
{
    int x, n ;
    char wahl ;
    roulett test ;

    test.geld = 50 ;

    srand((unsigned) time(NULL));

    for(;;)
    {

       /*   Zahl generieren    */
       test.zahl=rand()%37;

       cout &lt;&lt; &quot;\nWie oft wollen sie setzen?\n&quot; ;
       cin &gt;&gt; x ;
       cout &lt;&lt; &quot;&lt;z&gt; auf Zahl tippen\n&lt;g&gt; auf grade oder ungrade tippen&quot; ;
       cin &gt;&gt; wahl ; 

       for(n=0;n&gt;x;n++)
       {
                 if( wahl == 'z' || wahl == 'Z' )
                 {
                     test.vzahl();
                 }
                 else
                 {
                     test.vgerade();
                 }       
       }

       cout &lt;&lt; test.geld ;     

    }      

    return 0;
}
</code></pre>
<p>Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976357</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976357</guid><dc:creator><![CDATA[noha_391]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:12:30 GMT</pubDate></item><item><title><![CDATA[Reply to Roulett-problem on Wed, 25 Jan 2006 20:36:39 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">for(n=0;n&gt;x;n++)
       {
</code></pre>
<p>Das wird glaube ich nicht so funktionieren, da x ja die Anzahl ist, wie oft man setzen will, aber dann ist es ja auf jeden fall GRÖSSER als 0 und nicht kleiner. Also ist n&gt;x für n=0 immer false. Die for-Schleife wird deswegen nicht ausgeführt.</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976382</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:36:39 GMT</pubDate></item><item><title><![CDATA[Reply to Roulett-problem on Wed, 25 Jan 2006 20:41:09 GMT]]></title><description><![CDATA[<p>joomoo schrieb:</p>
<blockquote>
<pre><code class="language-cpp">for(n=0;n&gt;x;n++)
       {
</code></pre>
<p>Das wird glaube ich nicht so funktionieren, da x ja die Anzahl ist, wie oft man setzen will, aber dann ist es ja auf jeden fall GRÖSSER als 0 und nicht kleiner. Also ist n&gt;x für n=0 immer false. Die for-Schleife wird deswegen nicht ausgeführt.</p>
<p>mfg.</p>
</blockquote>
<p>das stimmt alles, aber kurz gesagt:</p>
<p>dreh die spitze Klammer um in &lt;</p>
<p>also:</p>
<pre><code class="language-cpp">for(n=0; n&lt;x; n++)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/976389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976389</guid><dc:creator><![CDATA[xindon]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:41:09 GMT</pubDate></item></channel></rss>