<?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[Vergleiche im Array]]></title><description><![CDATA[<p>*nochmal meld* :&gt;</p>
<p>Wie realisiert man das Zählen des gleichen Inhaltes in einem Array?<br />
Wenn ich ein Int-Array habe:</p>
<p>int test[5] = 1,2,2,3,4;</p>
<p>Soll ausgegeben werden: Es treten '2' gleiche Felder auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/198131/vergleiche-im-array</link><generator>RSS for Node</generator><lastBuildDate>Thu, 01 Oct 2026 20:28:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198131.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 Nov 2007 21:30:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 21:30:08 GMT]]></title><description><![CDATA[<p>*nochmal meld* :&gt;</p>
<p>Wie realisiert man das Zählen des gleichen Inhaltes in einem Array?<br />
Wenn ich ein Int-Array habe:</p>
<p>int test[5] = 1,2,2,3,4;</p>
<p>Soll ausgegeben werden: Es treten '2' gleiche Felder auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1405581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405581</guid><dc:creator><![CDATA[Keydo]]></dc:creator><pubDate>Sun, 18 Nov 2007 21:30:08 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 21:35:43 GMT]]></title><description><![CDATA[<p>Wenn das Array wie in deinem Beispiel sortiert ist, ist's wohl sehr einfach... Wenn's unsortiert ist, sortierst du's halt und dann ist es wieder einfach <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Bei sortiertem Array:</p>
<pre><code>Für alle Einträge mache
    cur := aktueller_eintrag
    count := 0
    Solange aktueller_eintrag == cur
       count := count + 1
       aktueller_eintrag = nächster_eintrag
    Gebe aus: [count] &quot; Anzahlen&quot;
</code></pre>
<p>Und du musst dir überlegen, was z.B. hierbei ausgegeben werden soll: {1,1,1,1,2,2,3,5,777}.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1405585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405585</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sun, 18 Nov 2007 21:35:43 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 21:36:16 GMT]]></title><description><![CDATA[<p>oh cool, ^^</p>
<p>nach da sortier ich dat ma flink 8P merci</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1405586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405586</guid><dc:creator><![CDATA[Keydo]]></dc:creator><pubDate>Sun, 18 Nov 2007 21:36:16 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 21:42:42 GMT]]></title><description><![CDATA[<pre><code>int myArray[6] = { 5, 3, 5, 1, 1, 4 };
	int myArrayLen = 6;

	// wert, anzahl
	std::map&lt;int, int&gt; statistics;
	for(int i = 0; i &lt; myArrayLen; ++i)
	{
		int key = myArray[i];
		++statistics[key];
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1405590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405590</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Sun, 18 Nov 2007 21:42:42 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 22:13:36 GMT]]></title><description><![CDATA[<p>@ badestrand, dann soll er sagen *grübel* es gibt halt 3 Zahlen die gleich oft vorkommen... oder so^^</p>
<p>momentan endet das in einer Endloschleife:</p>
<pre><code class="language-cpp">for(int i = 25; i &gt; 0; i--)
		if(count[i] != 0)
			cout &lt;&lt; setw(3) &lt;&lt; count[i];
	for(int i = 0; i &lt; 25; i--)
	{
		int pick = count[i];
		int xcount = 0;
		while (count[i] == pick)
		{
			xcount++;
			pick = count[i+1];
		}
       cout &lt;&lt; count &lt;&lt; endl;
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1405611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405611</guid><dc:creator><![CDATA[Keydo]]></dc:creator><pubDate>Sun, 18 Nov 2007 22:13:36 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 22:18:35 GMT]]></title><description><![CDATA[<p>dein zweiter schleifenzähler zählt ins minus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1405614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405614</guid><dc:creator><![CDATA[life_drake]]></dc:creator><pubDate>Sun, 18 Nov 2007 22:18:35 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 22:42:07 GMT]]></title><description><![CDATA[<p>life_drake schrieb:</p>
<blockquote>
<p>dein zweiter schleifenzähler zählt ins minus</p>
</blockquote>
<p>Und die innere Schleife überhaupt nicht.. Aber simon.gysi hat Recht, mit einer map ist's eine Ecke einfacher (obwohl es manuell eine bessere Übung für dich ist) <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/1405623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405623</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sun, 18 Nov 2007 22:42:07 GMT</pubDate></item><item><title><![CDATA[Reply to Vergleiche im Array on Sun, 18 Nov 2007 23:39:55 GMT]]></title><description><![CDATA[<p>std::map ist eine Lösung, std::sort und dann durchzählen wäre die 2. die mir einfällt.<br />
Beide sollten in O(N log N) laufen, aber die std::sort Variante wird ziemlich sicher linear schneller sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1405634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1405634</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 18 Nov 2007 23:39:55 GMT</pubDate></item></channel></rss>