<?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[mein eigenes bouncing ball programm]]></title><description><![CDATA[<p>hallo,<br />
vor einigen tagen habe ich hier ein sehr schlechtes beispiel von ein bouncing ball programm geposted.<br />
ich habe jetzt mein eigenes programm geschrieben und würde gerne wissen ob ich schwerwigende stil fehler gemacht habe ?<br />
btw gibt es eine möglichekit den source code in VS2010 zu formatieren ? ;/</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;stdlib.h&gt;

using namespace std;

void bounce(int &amp;start, int &amp;end)
{   
	static int cnt =0;
	string toright, toleft;
	while (true) // endless
	{	
	for(; start!=end; ++start)		
	{
		system(&quot;cls&quot;);

			for (size_t sz=0; sz!=cnt;++sz)   // newline
			{
				cout &lt;&lt; &quot;\n&quot;;
			}

			++cnt;
			for (size_t sz = 0; sz!=start; ++sz)
			{
				toright += ' '; // space from left to right
			}
			cout &lt;&lt; toright&lt;&lt;&quot;O&quot;;
			toright =&quot;&quot;;
			}

	for(; start!=0; --start)		
	{
		system(&quot;cls&quot;);

			for (size_t sz=0; sz!=cnt;++sz)   // newline
			{
				cout &lt;&lt; &quot;\n&quot;;
			}
			++cnt;
			if (start !=0)
			{
			for (size_t sz =0; sz!=start; ++sz)
			{
				toleft += ' '; // space from right to left
			}
			cout &lt;&lt; toleft&lt;&lt;&quot;O&quot;;
			}
			else
			{
				cout &lt;&lt; &quot;O&quot;;
			}
			toleft =&quot;&quot;;

	}

}
}

int main()
{   
   int a=0, b=15;
   bounce(a,b);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/291293/mein-eigenes-bouncing-ball-programm</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 20:37:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/291293.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Aug 2011 00:54:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to mein eigenes bouncing ball programm on Mon, 15 Aug 2011 00:54:27 GMT]]></title><description><![CDATA[<p>hallo,<br />
vor einigen tagen habe ich hier ein sehr schlechtes beispiel von ein bouncing ball programm geposted.<br />
ich habe jetzt mein eigenes programm geschrieben und würde gerne wissen ob ich schwerwigende stil fehler gemacht habe ?<br />
btw gibt es eine möglichekit den source code in VS2010 zu formatieren ? ;/</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;stdlib.h&gt;

using namespace std;

void bounce(int &amp;start, int &amp;end)
{   
	static int cnt =0;
	string toright, toleft;
	while (true) // endless
	{	
	for(; start!=end; ++start)		
	{
		system(&quot;cls&quot;);

			for (size_t sz=0; sz!=cnt;++sz)   // newline
			{
				cout &lt;&lt; &quot;\n&quot;;
			}

			++cnt;
			for (size_t sz = 0; sz!=start; ++sz)
			{
				toright += ' '; // space from left to right
			}
			cout &lt;&lt; toright&lt;&lt;&quot;O&quot;;
			toright =&quot;&quot;;
			}

	for(; start!=0; --start)		
	{
		system(&quot;cls&quot;);

			for (size_t sz=0; sz!=cnt;++sz)   // newline
			{
				cout &lt;&lt; &quot;\n&quot;;
			}
			++cnt;
			if (start !=0)
			{
			for (size_t sz =0; sz!=start; ++sz)
			{
				toleft += ' '; // space from right to left
			}
			cout &lt;&lt; toleft&lt;&lt;&quot;O&quot;;
			}
			else
			{
				cout &lt;&lt; &quot;O&quot;;
			}
			toleft =&quot;&quot;;

	}

}
}

int main()
{   
   int a=0, b=15;
   bounce(a,b);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2106166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106166</guid><dc:creator><![CDATA[kantaki]]></dc:creator><pubDate>Mon, 15 Aug 2011 00:54:27 GMT</pubDate></item><item><title><![CDATA[Reply to mein eigenes bouncing ball programm on Mon, 15 Aug 2011 01:34:52 GMT]]></title><description><![CDATA[<p>Erstmal solltest du sagen was die Funkttion überhaupt machen soll. Was mir spontan ins Auge fällt:<br />
-<em>#include &lt;vector&gt;</em> Wozu?<br />
-<em>#include &lt;string&gt;</em> Wozu?<br />
-Auflösung des <em>std</em>-Namenraums (kein Fehler, kann jedoch gefährlich werden).<br />
-<em>static int cnt =0;</em> Eine statische Variable innerhalb einer Funktion ist nicht notwendig. Was wolltest du damit bezwecken?<br />
-<em>while (true)</em> Warum eine Endlosschleife? In den meisten Fällen ist eine solche nur ein Indikator schlechten Designs.<br />
-<em>system(&quot;cls&quot;);</em> Umstrittene Art und Weise den Konsolenoutput zu terminieren. Da es mir scheint als wolltest du ein Spiel programmieren, würde ich dir eher zu &quot;Reading Input Buffer Events&quot; raten. Einen Einstieg solltest du hier finden:<br />
<a href="http://msdn.microsoft.com/en-us/library/ms685035(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms685035(v=vs.85).aspx</a></p>
<p>Ansonsten fällt mir so nichts auf. Logik/Mathematik habe ich nicht berücksichtigt, da ich nicht ahne was der Code machen soll.</p>
<p>Gute Nacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106173</guid><dc:creator><![CDATA[Kóyaánasqatsi]]></dc:creator><pubDate>Mon, 15 Aug 2011 01:34:52 GMT</pubDate></item><item><title><![CDATA[Reply to mein eigenes bouncing ball programm on Mon, 15 Aug 2011 04:12:54 GMT]]></title><description><![CDATA[<p>Kóyaánasqatsi schrieb:</p>
<blockquote>
<p>-<em>#include &lt;string&gt;</em> Wozu?</p>
</blockquote>
<p>Für Zeile 11? :p</p>
<p>@TE<br />
int's kannst du ruhig einfach so übergeben, Referenzen sind da eher unüblich. Es gibt zwei Gründe für Referenzen: 1. Man will Speicher sparen (dann mit const TYP&amp; variable) 2. Man will den Wert der übegebenen Variablen auch außerhalb der Funktion ändern. Beides trifft bei dir nicht zu. (sizeof(void*) &lt;&lt; sizeof(int) schließe ich mal aus.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106175</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Mon, 15 Aug 2011 04:12:54 GMT</pubDate></item><item><title><![CDATA[Reply to mein eigenes bouncing ball programm on Mon, 15 Aug 2011 07:06:15 GMT]]></title><description><![CDATA[<p>kantaki schrieb:</p>
<blockquote>
<p>btw gibt es eine möglichekit den source code in VS2010 zu formatieren ? ;/</p>
</blockquote>
<p>Strg+A Alt+F8</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106201</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106201</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 15 Aug 2011 07:06:15 GMT</pubDate></item><item><title><![CDATA[Reply to mein eigenes bouncing ball programm on Mon, 15 Aug 2011 07:51:35 GMT]]></title><description><![CDATA[<p>oder Strg + K + F<br />
und halt vorher alles markieren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106220</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Mon, 15 Aug 2011 07:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to mein eigenes bouncing ball programm on Mon, 15 Aug 2011 11:26:49 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p>Kóyaánasqatsi schrieb:</p>
<blockquote>
<p>-<em>#include &lt;string&gt;</em> Wozu?</p>
</blockquote>
<p>Für Zeile 11? :p</p>
<p>@TE<br />
int's kannst du ruhig einfach so übergeben, Referenzen sind da eher unüblich. Es gibt zwei Gründe für Referenzen: 1. Man will Speicher sparen (dann mit const TYP&amp; variable) 2. Man will den Wert der übegebenen Variablen auch außerhalb der Funktion ändern. Beides trifft bei dir nicht zu. (sizeof(void*) &lt;&lt; sizeof(int) schließe ich mal aus.)</p>
</blockquote>
<p>hey danke, ich hab das programm um 2 uhr morgens geschrieben, ich weiß garnicht warum ich referenzen benutzt habe, gibt irgentwie auch keinen sinn :p</p>
<p>@ first post :<br />
ich hab mir ein template geschrieben das alle #includes beinhaltet die ich städnig brauche, bin zu faul immer alles neu zuschreiben.</p>
<p>sehr schön alt+f8 spart ne menge zeit <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/2106300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106300</guid><dc:creator><![CDATA[kantaki]]></dc:creator><pubDate>Mon, 15 Aug 2011 11:26:49 GMT</pubDate></item></channel></rss>