<?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[Container Eintrag]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte, daß in eine Zahlenliste in einem vector-Container eine Zahl nur dann mit push.back eingetragen wird, wenn sie dort noch nicht vorhanden ist.</p>
<p>Wie kann ich das machen?</p>
<p>Die if-Struktur stellt kein Problem für mich da, nur wie die If-Struktur den Inhalt des Containers prüft ....</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321119/container-eintrag</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 13:14:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321119.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Oct 2013 18:57:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Container Eintrag on Thu, 24 Oct 2013 18:57:17 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte, daß in eine Zahlenliste in einem vector-Container eine Zahl nur dann mit push.back eingetragen wird, wenn sie dort noch nicht vorhanden ist.</p>
<p>Wie kann ich das machen?</p>
<p>Die if-Struktur stellt kein Problem für mich da, nur wie die If-Struktur den Inhalt des Containers prüft ....</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362708</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Thu, 24 Oct 2013 18:57:17 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Thu, 24 Oct 2013 19:02:29 GMT]]></title><description><![CDATA[<pre><code>if ( std::find(std::begin(vec), std::end(vec), myX) == std::end(vec) )
    vec.push_back(myX);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2362710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362710</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Thu, 24 Oct 2013 19:02:29 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Thu, 24 Oct 2013 19:04:30 GMT]]></title><description><![CDATA[<p>Danke, probier es gleich mal aus ....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362711</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Thu, 24 Oct 2013 19:04:30 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Thu, 24 Oct 2013 19:11:15 GMT]]></title><description><![CDATA[<p>PS: Normalerweise bietet sich für sowas std::set an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362713</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Thu, 24 Oct 2013 19:11:15 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 07:17:18 GMT]]></title><description><![CDATA[<p>funktioniert übrigens prima!</p>
<p>Kannst Du mir mal verraten, warum Du vor die Befehle dieses std:: machst? Ich kenn den Befehl nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362766</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Fri, 25 Oct 2013 07:17:18 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 07:18:19 GMT]]></title><description><![CDATA[<p>brak schrieb:</p>
<blockquote>
<p>funktioniert übrigens prima!</p>
<p>Kannst Du mir mal verraten, warum Du vor die Befehle dieses std:: machst? Ich kenn den Befehl nicht.</p>
</blockquote>
<p>muss man hinschreiben, denn diese klassentemplates / funktionstemplates sind im <strong>namensbereich</strong> std.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362769</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362769</guid><dc:creator><![CDATA[not smart]]></dc:creator><pubDate>Fri, 25 Oct 2013 07:18:19 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 07:23:13 GMT]]></title><description><![CDATA[<p>Es sei denn man ist böse und schreibt using namespace std;.<br />
Aber zum Glück würde man dass ja niemals machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362770</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 25 Oct 2013 07:23:13 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 11:02:57 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Es sei denn man ist böse und schreibt using namespace std;.<br />
Aber zum Glück würde man dass ja niemals machen.</p>
</blockquote>
<p>das heißt konkret, wenn ich using namespace std deklariert habe im haeder oben, kann ich alle std:: entfernen aus dem Text, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362854</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Fri, 25 Oct 2013 11:02:57 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 11:14:08 GMT]]></title><description><![CDATA[<p>Ja.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362856</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 25 Oct 2013 11:14:08 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 11:31:49 GMT]]></title><description><![CDATA[<p>brak schrieb:</p>
<blockquote>
<p>das heißt konkret, wenn ich using namespace std deklariert habe <strong>im haeder oben</strong>, kann ich alle std:: entfernen aus dem Text, oder?</p>
</blockquote>
<p>theoretisch ja, aber in einem Header hat das nichts zu suchen. Wenn du diese Headerdatei irgendwoanders einbindest, dann ist dort nämlich auch der Namensraum std &quot;frei&quot;. Und das wollen erfahrene Programmierer nicht, weil es zu Namenskollisionen kommen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362861</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362861</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Fri, 25 Oct 2013 11:31:49 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 12:05:45 GMT]]></title><description><![CDATA[<p>Das wollen auch unerfahrene Programmierer nicht. Es hebelt halt das gesamte Konzept von Namensräumen aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362875</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 25 Oct 2013 12:05:45 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 12:14:52 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>Es hebelt halt das gesamte Konzept von Namensräumen aus.</p>
</blockquote>
<p>Das stimmt so nicht. Im Falle einer Kollision kann man den Namensraum auch einfach explizit angeben.</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>Es hebelt halt das gesamte Konzept von Namensräumen aus.</p>
</blockquote>
<p>Unerfahrene Programmierer wollen das. Bjarnes std_lib_facilities.h hat ein &quot;using namespace std;&quot; drin.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362878</guid><dc:creator><![CDATA[langer hebel]]></dc:creator><pubDate>Fri, 25 Oct 2013 12:14:52 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 12:26:17 GMT]]></title><description><![CDATA[<p>Das Progrämmchen läuft, ist wohl nicht nach der reinen Lehre notiert, aber es läuft ....</p>
<p>Der fragliche Code ist beim einzigen find. dort hätt ich gerne die std's raus.</p>
<p>Jetzt noch was. Ich möchte, daß in der letzten Liste, wo die existenten Teilersummen aufgeführt werden, hinter jeder Zeilersumme alle die Zahlen erscheinen, wie diese Zahl Teilersumme ist. Wie mach ich das am besten?</p>
<p>Ich will also an die Elemente von Teilersummensammler hinten eine offen Schlange von Elementen anheften lassen. Das passiert bei hinter bei dem If und danach in einem noch zu setzenden else...</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;

int quot;
int Testzahl=0;
int Testbeginn;
int Testende;
int Zehler=0;
int PrimZahlZeler=0;
int Teilerzeler=0;
int NichtTrivialeTeilerSumme=0;
int TeilerSumme=0; //Teilersumme
vector&lt;int&gt;Teiler(0);
vector&lt;int&gt;TeilerSummenSammler(0);
vector&lt;int&gt;newsort(0);
//vector&lt;int&gt;NTTS(0); //NichttrivialeTeilersumme

int main ()
{
    cout&lt;&lt; &quot;Geben Sie die Anfangszahl des Bereiches ein: &quot;;
    cin&gt;&gt;Testbeginn;
    cout&lt;&lt; &quot;Geben Sie die Endzahl des Bereiches ein: &quot;;
    cin&gt;&gt;Testende;

    for(int a=Testbeginn;a&lt;=Testende;a++)
        {
            Testzahl=a;

        for(int i=1;i&lt;=Testzahl;i=i+1)
            {
                quot=Testzahl/i;
                if(0==Testzahl%i)
                {
                    quot=Testzahl/i;
                    Zehler=Zehler+1;
                    Teiler.push_back(quot);
                    //cout&lt;&lt;&quot; &quot;&lt;&lt;quot &lt;&lt;&quot; ist der &quot;&lt;&lt;Zehler&lt;&lt;&quot;. Teiler der Zahl &quot;&lt;&lt;Testzahl&lt;&lt;&quot;.  \n&quot;;
                    TeilerSumme=TeilerSumme+quot;
                }
            }

            if (Teiler.size()==2)
            {
               cout&lt;&lt;Testzahl&lt;&lt;&quot; (prim) \n&quot;;
                PrimZahlZeler++;
             }
            else if (Teiler.size()!=2)
                {
                cout&lt;&lt;Testzahl&lt;&lt;&quot; - &quot;&lt;&lt;Zehler&lt;&lt;&quot; T. &quot;;
                for(auto it=Teiler.begin();it!=Teiler.end();it++)
                    {
                        cout&lt;&lt;*it;
                        if( it!=Teiler.end()-1 )
                        cout&lt;&lt;&quot;+&quot;;

                   }
                    NichtTrivialeTeilerSumme=TeilerSumme-Testzahl-1;
                     cout&lt;&lt;&quot;= &quot;&lt;&lt;TeilerSumme&lt;&lt;&quot;=TS,&quot;&lt;&lt;NichtTrivialeTeilerSumme&lt;&lt;&quot;=NTTS.\n&quot;;

                    if ( std::find(std::begin(TeilerSummenSammler), std::end(TeilerSummenSammler), TeilerSumme) == std::end(TeilerSummenSammler) )
                        {
                            TeilerSummenSammler.push_back(TeilerSumme);
                        }

            }

            TeilerSumme=0;
            Teiler.clear();
            Zehler=0;
        }
std: sort(TeilerSummenSammler.begin(),TeilerSummenSammler.end());
    cout&lt;&lt;&quot;Dies sind die existenten Teilersummen des Bereiches bis &quot;&lt;&lt;Testende&lt;&lt; endl;

for(auto it=TeilerSummenSammler.begin();it!=TeilerSummenSammler.end();it++)
            {
                Teilerzeler=Teilerzeler+1;
                cout&lt;&lt;Teilerzeler&lt;&lt;&quot;. &quot;&lt;&lt;*it;
                cout&lt;&lt;&quot; &quot;&lt;&lt;endl;
            }
cout&lt;&lt;&quot;Es gibt im Bereich von &quot;&lt;&lt;Testbeginn&lt;&lt;&quot; bis &quot;&lt;&lt;Testende&lt;&lt;&quot; genau &quot;&lt;&lt;PrimZahlZeler&lt;&lt;&quot; PrimZahlen und &quot; &lt;&lt;Teilerzeler&lt;&lt;&quot; verschiedene Teilersummen.&quot;;

    return (0);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2362880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362880</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Fri, 25 Oct 2013 12:26:17 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 12:45:42 GMT]]></title><description><![CDATA[<p>Ist nicht so guter Code. Allein schon von der Formatierung her nicht.</p>
<p>1. Vermeide Globale Variablen, zumal du sie hier eh nicht brauchst.<br />
2. Zeile 77: &quot;std: sort&quot;... Das ist nicht so ganz korrekt.<br />
3. Zeile 4 hat die namespace Direktive, wieso dann &quot;std::&quot; nochmal explizit angeben?<br />
4. Wenn du keine doppelten Einträge haben willst, dann nimm doch gleich std::set, statt vector.<br />
5. ich versteh wegen unglücklicher Formulierung deine Frage nicht/bzgl. Teilersummen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362887</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 25 Oct 2013 12:45:42 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 13:59:15 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>1. Vermeide Globale Variablen, zumal du sie hier eh nicht brauchst.</p>
</blockquote>
<p>Was sind &quot;globale Variablen&quot;? Ich vermute, Du meinst die int-Variablen im Haeder?</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>2. Zeile 77: &quot;std: sort&quot;... Das ist nicht so ganz korrekt.</p>
</blockquote>
<p>Hab ich gelöscht, jetzt funktioniert es so.</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>3. Zeile 4 hat die namespace Direktive, wieso dann &quot;std::&quot; nochmal explizit angeben?</p>
</blockquote>
<p>Aha, wenn &quot;Using namespace std:&quot; steht, braucht in den Code das std nicht mehr ein. Hab ich das recht verstanden?</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>4. Wenn du keine doppelten Einträge haben willst, dann nimm doch gleich std::set, statt vector.</p>
</blockquote>
<p>Den Befehl kenn ich überhaupt nicht, steht auch in meinem c++ Heft nicht drin, glaub ich...</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>5. ich versteh wegen unglücklicher Formulierung deine Frage nicht/bzgl. Teilersummen)</p>
</blockquote>
<p>Laß den Code mal laufen. Er zeigt am Ende eine Liste von Zahlen, die in dem eingegebenen Bereich als Teilersummen auftreten. Ich möchte jetzt noch, daß hinter den Zahlen(Teilersummen) angegeben wird, bei welchen Zahlen diese Teilersummen auftreten. Es müßte nach dem if Zeile 71 eingebaut werden.</p>
<p>Bei dem Find-Befehl, kann ich da einfach die std's mit den beiden Doppelpunkten rauslöschen?</p>
<p>Danke für die Hilfestellung!:-)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362901</guid><dc:creator><![CDATA[brak]]></dc:creator><pubDate>Fri, 25 Oct 2013 13:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 17:03:03 GMT]]></title><description><![CDATA[<blockquote>
<p>Was sind &quot;globale Variablen&quot;?</p>
</blockquote>
<p>Variablen, die global deklariert wurden, also außerhalb einer Funktion oder Klasse.</p>
<blockquote>
<p>Aha, wenn &quot;Using namespace std:&quot; steht, braucht in den Code das std nicht mehr ein. Hab ich das recht verstanden?</p>
</blockquote>
<p>Ja.</p>
<blockquote>
<p>Den Befehl kenn ich überhaupt nicht, steht auch in meinem c++ Heft nicht drin, glaub ich...</p>
</blockquote>
<p>Das ist kein Befehl, sondern ein assoziativer Container, der seine Elemente nicht einfach in fester Reihenfolge hintereinander abspeichert, sondern nach einer (festlegbaren) Ordnungsrelation. Der lässt sich ähnlich wie <code>vector</code> bedienen, funktioniert aber grundsätzlich anders.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362951</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Fri, 25 Oct 2013 17:03:03 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 17:41:47 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<blockquote>
<p>Den Befehl kenn ich überhaupt nicht, steht auch in meinem c++ Heft nicht drin, glaub ich...</p>
</blockquote>
<p>Das ist kein Befehl, sondern ein assoziativer Container, der seine Elemente nicht einfach in fester Reihenfolge hintereinander abspeichert, sondern nach einer (festlegbaren) Ordnungsrelation. Der lässt sich ähnlich wie <code>vector</code> bedienen, funktioniert aber grundsätzlich anders.</p>
</blockquote>
<p>YMMD <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><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19589">@brak</a>: von welchem Header sprichst du? Du hast keinen Header geschrieben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362954</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 25 Oct 2013 17:41:47 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 19:11:16 GMT]]></title><description><![CDATA[<p>Seit wann ist set assoziativ? oO</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362979</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362979</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 25 Oct 2013 19:11:16 GMT</pubDate></item><item><title><![CDATA[Reply to Container Eintrag on Fri, 25 Oct 2013 19:23:57 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>Seit wann ist set assoziativ? oO</p>
</blockquote>
<p>Seit Anbeginn der Zeit. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
<p><a href="http://en.cppreference.com/w/cpp/container" rel="nofollow">http://en.cppreference.com/w/cpp/container</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2362982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2362982</guid><dc:creator><![CDATA[Wächter der Zeit]]></dc:creator><pubDate>Fri, 25 Oct 2013 19:23:57 GMT</pubDate></item></channel></rss>