<?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[Modulo-Problem]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;
int diverg;
int zahl;
int teiler;
int ugnpz=1;
int pzz=2;
int p1=3;
int p2=1;

int main()
{
    for(zahl=1; zahl&lt;=1000; zahl=zahl+2) //Zahlhersteller
    {
        for(teiler=2; teiler&lt;=zahl/2; teiler=teiler+1) //Primzahlprüfer
        {
            diverg = zahl%teiler;
            if (diverg == 0)
            {
                ugnpz=ugnpz+1;
               cout&lt;&lt;zahl&lt;&lt;&quot; ist die &quot;&lt;&lt;ugnpz&lt;&lt;&quot;. uNPZ     &quot;&lt;&lt;pzz&lt;&lt;&quot;/&quot;&lt;&lt;ugnpz&lt;&lt;&quot; = &quot;&lt;&lt;pzz/ugnpz&lt;&lt;&quot;,&quot;&lt;&lt;pzz%ugnpz&lt;&lt;&quot;          UGZDistanz = &quot;&lt;&lt;((zahl-p2)/2)-1&lt;&lt;&quot;\n&quot;;
                p2=zahl;
                break;
            }
            else
            {
                if (teiler == (zahl-1)/2)
                {
                    pzz=pzz+1;
                    cout&lt;&lt;zahl&lt;&lt; &quot; ist die &quot;&lt;&lt;pzz&lt;&lt;&quot;.   PZ     &quot;&lt;&lt;pzz&lt;&lt;&quot;/&quot;&lt;&lt;ugnpz&lt;&lt;&quot; = &quot;&lt;&lt;pzz/ugnpz&lt;&lt;&quot;,&quot;&lt;&lt;pzz%ugnpz&lt;&lt;&quot; UGZDistanz = &quot;&lt;&lt;((zahl-p1)/2)-1&lt;&lt;&quot; \n&quot;; // Dies ist die wichtige richtige, nur wegen Pzpz auskommentiert.
                    p1=zahl;
                }
            }
        }
    }
    return 0;
}
</code></pre>
<p>Seht Euch mal den Nachkommawert in der 4 Zeile (PZ = 11) an. Da stimmt doch was nicht mit Modulo...</p>
<p>Wer hat den rettenden Tip?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/316625/modulo-problem</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 22:29:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316625.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 10 May 2013 18:34:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 18:34:47 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;
int diverg;
int zahl;
int teiler;
int ugnpz=1;
int pzz=2;
int p1=3;
int p2=1;

int main()
{
    for(zahl=1; zahl&lt;=1000; zahl=zahl+2) //Zahlhersteller
    {
        for(teiler=2; teiler&lt;=zahl/2; teiler=teiler+1) //Primzahlprüfer
        {
            diverg = zahl%teiler;
            if (diverg == 0)
            {
                ugnpz=ugnpz+1;
               cout&lt;&lt;zahl&lt;&lt;&quot; ist die &quot;&lt;&lt;ugnpz&lt;&lt;&quot;. uNPZ     &quot;&lt;&lt;pzz&lt;&lt;&quot;/&quot;&lt;&lt;ugnpz&lt;&lt;&quot; = &quot;&lt;&lt;pzz/ugnpz&lt;&lt;&quot;,&quot;&lt;&lt;pzz%ugnpz&lt;&lt;&quot;          UGZDistanz = &quot;&lt;&lt;((zahl-p2)/2)-1&lt;&lt;&quot;\n&quot;;
                p2=zahl;
                break;
            }
            else
            {
                if (teiler == (zahl-1)/2)
                {
                    pzz=pzz+1;
                    cout&lt;&lt;zahl&lt;&lt; &quot; ist die &quot;&lt;&lt;pzz&lt;&lt;&quot;.   PZ     &quot;&lt;&lt;pzz&lt;&lt;&quot;/&quot;&lt;&lt;ugnpz&lt;&lt;&quot; = &quot;&lt;&lt;pzz/ugnpz&lt;&lt;&quot;,&quot;&lt;&lt;pzz%ugnpz&lt;&lt;&quot; UGZDistanz = &quot;&lt;&lt;((zahl-p1)/2)-1&lt;&lt;&quot; \n&quot;; // Dies ist die wichtige richtige, nur wegen Pzpz auskommentiert.
                    p1=zahl;
                }
            }
        }
    }
    return 0;
}
</code></pre>
<p>Seht Euch mal den Nachkommawert in der 4 Zeile (PZ = 11) an. Da stimmt doch was nicht mit Modulo...</p>
<p>Wer hat den rettenden Tip?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322508</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Fri, 10 May 2013 18:34:47 GMT</pubDate></item><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 18:40:01 GMT]]></title><description><![CDATA[<p>Dein Code ist echt kaum lesbar, vielleicht stelle ich mich auch an, aber die Namensvergebung könnte definitiv besser sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322509</guid><dc:creator><![CDATA[Unbekannter]]></dc:creator><pubDate>Fri, 10 May 2013 18:40:01 GMT</pubDate></item><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 18:56:18 GMT]]></title><description><![CDATA[<p>Welchen &quot;Nachkommawert&quot;? Du rechnest doch nur mit Ganzzahlen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322512</guid><dc:creator><![CDATA[Bekannter]]></dc:creator><pubDate>Fri, 10 May 2013 18:56:18 GMT</pubDate></item><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 19:09:08 GMT]]></title><description><![CDATA[<blockquote>
<p>Wer hat den rettenden Tip?</p>
</blockquote>
<p>Könntest du das Problem &quot;reduzieren&quot;?</p>
<p>Es gibt schließlich offensichtlich einen Unterschied zwischen der Ausgabe <em>die dein Programm erzeugt</em>, und der <em>die du erwartet hast</em>.<br />
Erst einmal könntest du diese beiden Ausgaben posten. Was du erwartet hast und was rauskam.</p>
<p>Dann könntest du diesen Unterschied reproduzieren, aber mit weniger Code.<br />
Etwas direkter. Dann kann man auch das Missverständnis besser sehen.</p>
<p>Keiner hat Lust, sich durch so ein Monstrum von schlecht eingerücktem und komisch programmiertem Code zu wühlen.<br />
Beachte auch <strong><a href="http://www.c-plusplus.net/forum/304133" rel="nofollow">Den richtigen Code posten: reduziertes compilierbares Beispiel</a></strong>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322515</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 10 May 2013 19:09:08 GMT</pubDate></item><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 20:02:08 GMT]]></title><description><![CDATA[<p>Das ist die Ausgabe: 11 ist die 5. PZ <strong>5/2 = 2,1</strong> UGZDistanz = 1</p>
<p>Ich erwarte bei 5/2 2,5 als Ausgabe.</p>
<p>Es bezieht sich auf Zeile 33 des Codes</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322526</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Fri, 10 May 2013 20:02:08 GMT</pubDate></item><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 20:27:09 GMT]]></title><description><![CDATA[<p>brak schrieb:</p>
<blockquote>
<p>Das ist die Ausgabe: 11 ist die 5. PZ <strong>5/2 = 2,1</strong> UGZDistanz = 1</p>
</blockquote>
<p>Das ist völlig richtig so. <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>5</mn><mtext> </mtext><mi>m</mi><mi>o</mi><mi>d</mi><mtext> </mtext><mn>2</mn><mtext> </mtext><mo>=</mo><mtext> </mtext><mn>1</mn></mrow><annotation encoding="application/x-tex">5 ~mod~ 2 ~=~ 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.69444em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathrm">5</span><span class="mord mspace"> </span><span class="mord mathit">m</span><span class="mord mathit">o</span><span class="mord mathit">d</span><span class="mord mspace"> </span><span class="mord mathrm">2</span><span class="mord mspace"> </span><span class="mrel">=</span><span class="mord mspace"> </span><span class="mord mathrm">1</span></span></span></span><br />
Deine &quot;Nachkommastelle&quot;, sprich die Zahl die nach dem Komma kommt, wird durch den Modulo des Dividenden und Divisors &quot;berechnet&quot;.</p>
<p>Wieo hast du erwartet <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>5</mn><mtext> </mtext><mi>m</mi><mi>o</mi><mi>d</mi><mtext> </mtext><mn>2</mn><mtext> </mtext><mo>=</mo><mtext> </mtext><mn>5</mn></mrow><annotation encoding="application/x-tex">5 ~mod~ 2 ~=~ 5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.69444em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathrm">5</span><span class="mord mspace"> </span><span class="mord mathit">m</span><span class="mord mathit">o</span><span class="mord mathit">d</span><span class="mord mspace"> </span><span class="mord mathrm">2</span><span class="mord mspace"> </span><span class="mrel">=</span><span class="mord mspace"> </span><span class="mord mathrm">5</span></span></span></span>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322527</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 10 May 2013 20:27:09 GMT</pubDate></item><item><title><![CDATA[Reply to Modulo-Problem on Fri, 10 May 2013 20:26:55 GMT]]></title><description><![CDATA[<p>Wenn du bei einer Division die erste Nachkommastelle berechnen möchtest, geht das folgendermaßen:<br />
Du multiplizierst den Dividenden mit 10 und ermittelst den Rest der Division durch den ursprünglichen Divisor.</p>
<p>Beispiel:</p>
<pre><code>#include &lt;iostream&gt;

int main()
{
    int a, b;
    std::cin &gt;&gt; a &gt;&gt; b;

    std::cout &lt;&lt; &quot;Erste Nachkommastelle: &quot; &lt;&lt; (a * 10) / b % 10;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2322530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322530</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 10 May 2013 20:26:55 GMT</pubDate></item></channel></rss>