<?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[ANfängerprobleme: Schleifen]]></title><description><![CDATA[<p>Hallo ich glaube die Aufgabenstellung ist zurzeit irrelevant, jedoch formuliere ich sie mal schnell trotzdem. Ich muss den Wert bestimmen welcher herauskommen würde wenn mal jede Zahl von 1 bis n hochrechnet und zusammen addiert.<br />
(also 1^1 +2^2 +3^3 +...+n n für eine beliebige natürliche Zahl n).<br />
Die Verwendung von mathematischen Funktionen (wie z.B. pow aus cmath) ist nicht erlaubt. Jedoch macht mein Programm schon nach der Eingabe der Zahl nicht weiter und ich komme nicht auf die Lösung. Ich hoffe ihr könnt mir helfen :).</p>
<pre><code>int main(){
int n, ergebnis = 0,endergebnis = 0;
cout &lt;&lt; &quot;Geben Sie eine Zahl ein&quot;;
cin &gt;&gt; n;
for (int i=n;i&gt;0;i--)
{
ergebnis = i; //Da muss schon der Fehler liegen bzw vorher.
	for (int j=i;i&gt;0;j--)
        { 
	ergebnis = ergebnis*i;
         }
endergebnis = endergebnis+ergebnis;
}
cout &lt;&lt; &quot;Das Endergebnis lautet: &quot; &lt;&lt; endergebnis &lt;&lt; &quot;\n&quot;;

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/340317/anfängerprobleme-schleifen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 08:35:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/340317.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 Oct 2016 09:37:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 09:37:56 GMT]]></title><description><![CDATA[<p>Hallo ich glaube die Aufgabenstellung ist zurzeit irrelevant, jedoch formuliere ich sie mal schnell trotzdem. Ich muss den Wert bestimmen welcher herauskommen würde wenn mal jede Zahl von 1 bis n hochrechnet und zusammen addiert.<br />
(also 1^1 +2^2 +3^3 +...+n n für eine beliebige natürliche Zahl n).<br />
Die Verwendung von mathematischen Funktionen (wie z.B. pow aus cmath) ist nicht erlaubt. Jedoch macht mein Programm schon nach der Eingabe der Zahl nicht weiter und ich komme nicht auf die Lösung. Ich hoffe ihr könnt mir helfen :).</p>
<pre><code>int main(){
int n, ergebnis = 0,endergebnis = 0;
cout &lt;&lt; &quot;Geben Sie eine Zahl ein&quot;;
cin &gt;&gt; n;
for (int i=n;i&gt;0;i--)
{
ergebnis = i; //Da muss schon der Fehler liegen bzw vorher.
	for (int j=i;i&gt;0;j--)
        { 
	ergebnis = ergebnis*i;
         }
endergebnis = endergebnis+ergebnis;
}
cout &lt;&lt; &quot;Das Endergebnis lautet: &quot; &lt;&lt; endergebnis &lt;&lt; &quot;\n&quot;;

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2513577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513577</guid><dc:creator><![CDATA[newprogrammer1996]]></dc:creator><pubDate>Mon, 31 Oct 2016 09:37:56 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 09:45:45 GMT]]></title><description><![CDATA[<p>Zeile 8: <code>i</code> vs. <code>j</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513580</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513580</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 31 Oct 2016 09:45:45 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 09:49:27 GMT]]></title><description><![CDATA[<p>Aja, wie konnte ich das nur übersehen, vielen Dank Swordfish!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513581</guid><dc:creator><![CDATA[newprogrammer1996]]></dc:creator><pubDate>Mon, 31 Oct 2016 09:49:27 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 10:14:17 GMT]]></title><description><![CDATA[<p>Mit einem Debugger kann man solche Fehler schnell finden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513584</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 31 Oct 2016 10:14:17 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 20:10:56 GMT]]></title><description><![CDATA[<p>Das geht auch mit einem Einzeiler:</p>
<pre><code>int n = 0, ergebnis = 0;
	cout &lt;&lt; &quot;Geben Sie eine Zahl ein: &quot; ;
	cin &gt;&gt; n;
	for (int i = n; i &gt; 0; ergebnis += i*i--);
	cout &lt;&lt; &quot;Das Ergebnis lautet: &quot; &lt;&lt; ergebnis &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Oder habe ich das falsch verstanden?<br />
Ich glaube nicht, wenn es wirklich &quot;n hoch n&quot; sein sollte, dann sprengst du ruckzuck die Grenzen eines ints.Wieviel ist z.B &quot;10 hoch 10&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513656</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Mon, 31 Oct 2016 20:10:56 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 20:09:34 GMT]]></title><description><![CDATA[<p>Ist die Auswertungsreihenfolge für <code>i*i--</code> garantiert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513657</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 31 Oct 2016 20:09:34 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 20:16:48 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<p>Ist die Auswertungsreihenfolge für <code>i*i--</code> garantiert?</p>
</blockquote>
<p>Hast du evtl recht, wegen der Priorität, dann eben:</p>
<pre><code>for (int i = n; i &gt; 0; ergebnis += i*i, i--);
</code></pre>
<p>Hat aber bei all meinen Tests korrekt funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513659</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Mon, 31 Oct 2016 20:16:48 GMT</pubDate></item><item><title><![CDATA[Reply to ANfängerprobleme: Schleifen on Mon, 31 Oct 2016 20:52:36 GMT]]></title><description><![CDATA[<p>EOP schrieb:</p>
<blockquote>
<p>Hat aber bei all meinen Tests korrekt funktioniert.</p>
</blockquote>
<p>UB heißt ja nicht: macht nicht das, was erwartet wird; sondern: macht was es will - was zufällig auch mal das Gewünschte sein kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513663</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 31 Oct 2016 20:52:36 GMT</pubDate></item></channel></rss>