<?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[Zahlen sortieren, Programm gibt aber nix aus]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ein Problem mit einem Cpp-Programm. Und zwar sollen Zahlen der Größe nach sortiert werden. Das Programm kann ich fehlerfrei ausführen, aber es gibt nichts aus. Ich habe mich auch schon mit dem Debugger dran versucht und bin nicht weitergekommen. Hier ist der Code.<br />
Hat vielleicht jemand eine Idee woran es liegen könnte?</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;	
using std::cout;
using std::endl;

//insertion sort, several errors

int X[10]={12,5,9,3,2,25,8,19,200,10}; //input array
int Y[10]; //workspace array
int NumInputs; //length of input array
int NumY=0; //current number of elements in Y

void GetArgs(int X[],int AC, char**AV)
{

	NumInputs=AC-1;
	for(int I=0; I&lt;NumInputs; I++)
		X[I]=atoi(AV[I+1]);	

void ScootOver(int JJ)
{

	for (int K=NumY-1; K&gt;JJ; K++)
		Y[K]=Y[K-1];
}

void Insert(int NewY)
{

	if(NumY==0)		//in der if-Bdg. muss '==' stehen, ansonsten hat NumY den Wert 0!
	{
		Y[0]=NewY;
		return ;
	}
	//need to insert just before the first Y
	//element that NewY is less than

	for(int J=0; J&lt;NumY; J++)
	{
		if (NewY&lt;Y[J])
		{
			//shift Y[J], Y[J+1],...rightward
			//before inserting NewY
			ScootOver(J);
			Y[J]=NewY;
			return;
		}
	}
}

void ProcessData()

{
	for(NumY=0; NumY&lt;NumInputs; NumY++)
		//insert new Y in the proper place
		//among Y[0],...,Y[NumY-1]
		Insert(X[NumY]);
}

void PrintResults()
{

	for(int I=0; I&lt;NumInputs; I++)
		cout&lt;&lt;Y[I]&lt;&lt;endl;
}

int main (int AC,char**Argv)
{
	GetArgs(X,AC, Argv);
	ProcessData();
	PrintResults();

	system(&quot;Pause&quot;);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/232749/zahlen-sortieren-programm-gibt-aber-nix-aus</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 05:07:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/232749.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Jan 2009 18:46:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zahlen sortieren, Programm gibt aber nix aus on Mon, 26 Jan 2009 18:46:24 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ein Problem mit einem Cpp-Programm. Und zwar sollen Zahlen der Größe nach sortiert werden. Das Programm kann ich fehlerfrei ausführen, aber es gibt nichts aus. Ich habe mich auch schon mit dem Debugger dran versucht und bin nicht weitergekommen. Hier ist der Code.<br />
Hat vielleicht jemand eine Idee woran es liegen könnte?</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;	
using std::cout;
using std::endl;

//insertion sort, several errors

int X[10]={12,5,9,3,2,25,8,19,200,10}; //input array
int Y[10]; //workspace array
int NumInputs; //length of input array
int NumY=0; //current number of elements in Y

void GetArgs(int X[],int AC, char**AV)
{

	NumInputs=AC-1;
	for(int I=0; I&lt;NumInputs; I++)
		X[I]=atoi(AV[I+1]);	

void ScootOver(int JJ)
{

	for (int K=NumY-1; K&gt;JJ; K++)
		Y[K]=Y[K-1];
}

void Insert(int NewY)
{

	if(NumY==0)		//in der if-Bdg. muss '==' stehen, ansonsten hat NumY den Wert 0!
	{
		Y[0]=NewY;
		return ;
	}
	//need to insert just before the first Y
	//element that NewY is less than

	for(int J=0; J&lt;NumY; J++)
	{
		if (NewY&lt;Y[J])
		{
			//shift Y[J], Y[J+1],...rightward
			//before inserting NewY
			ScootOver(J);
			Y[J]=NewY;
			return;
		}
	}
}

void ProcessData()

{
	for(NumY=0; NumY&lt;NumInputs; NumY++)
		//insert new Y in the proper place
		//among Y[0],...,Y[NumY-1]
		Insert(X[NumY]);
}

void PrintResults()
{

	for(int I=0; I&lt;NumInputs; I++)
		cout&lt;&lt;Y[I]&lt;&lt;endl;
}

int main (int AC,char**Argv)
{
	GetArgs(X,AC, Argv);
	ProcessData();
	PrintResults();

	system(&quot;Pause&quot;);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1652808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652808</guid><dc:creator><![CDATA[jiinex]]></dc:creator><pubDate>Mon, 26 Jan 2009 18:46:24 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlen sortieren, Programm gibt aber nix aus on Mon, 26 Jan 2009 19:54:06 GMT]]></title><description><![CDATA[<p>haste es denn auch gestartet mit</p>
<pre><code class="language-cpp">sort.exe 432 231 65 3 231 5 56
</code></pre>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652845</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 26 Jan 2009 19:54:06 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlen sortieren, Programm gibt aber nix aus on Mon, 26 Jan 2009 21:08:06 GMT]]></title><description><![CDATA[<p>Hallo volkard,</p>
<p>Ich benutze Visual C++ 2008 und habe es mit dem normalen Debug-Modus gestartet und dann kommt halt nix...</p>
<p>Bin gerade immer noch mit dem Debugger dran. Ein Fehler ist wohl, daß NumInputs den Wert 0 hat, aber ich weiß nicht genau wie ich das beheben koennte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652889</guid><dc:creator><![CDATA[jiinex]]></dc:creator><pubDate>Mon, 26 Jan 2009 21:08:06 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlen sortieren, Programm gibt aber nix aus on Mon, 26 Jan 2009 21:14:11 GMT]]></title><description><![CDATA[<p>jiinex schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int main (int AC,char**Argv)
</code></pre>
</blockquote>
<p>Du kannst zwar die Parameter benennen, wie du willst, aber du solltest dich vielleicht doch besser an die übliche Art (argc, argv) halten. Das macht es z.B. anderen leichter, die deinen Code lesen oder verwenden müssen.</p>
<p>EDIT: Starte die exe mit Kommandozeilenparametern. Dann siehst du sicher, dass es klappt. Wenn dem Programm keine Parameter übergeben werden, gibt's auch nix auszugeben. Im VS kannst du Kommandozeilenparameter festlegen (Debugging=&gt;Befehlsargumente).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652891</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652891</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 26 Jan 2009 21:14:11 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlen sortieren, Programm gibt aber nix aus on Mon, 26 Jan 2009 21:14:54 GMT]]></title><description><![CDATA[<p>jiinex schrieb:</p>
<blockquote>
<p>den Wert 0 hat, aber ich weiß nicht genau wie ich das beheben koennte.</p>
</blockquote>
<p>dann mach</p>
<pre><code class="language-cpp">int NumInputs=10;
</code></pre>
<p>und ruf GetArgs nicht auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652894</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 26 Jan 2009 21:14:54 GMT</pubDate></item></channel></rss>