<?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[Wie kann man 2 Array verschmelzen?]]></title><description><![CDATA[<p>Hallo an Alle,<br />
die aufgabe ist;<br />
<strong>Eingabe: 3 14 31 7 29 10 18 15 19 0 x=10<br />
Fg enhält dann 14 31 29 18 15 19 und Fk 3 7 10<br />
Ausgabe: 14 3 31 7 29 10 18 15 19</strong></p>
<p>f array habe ich schon in fg und fk reingeschrieben, aber wie ich nacheinander ausgebe komme ich nicht dazu. Ich bin im Moment beim Stof array , zeiger</p>
<p>danke euch nata</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/306565/wie-kann-man-2-array-verschmelzen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 07 Aug 2026 16:40:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/306565.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Aug 2012 11:54:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 11:54:37 GMT]]></title><description><![CDATA[<p>Hallo an Alle,<br />
die aufgabe ist;<br />
<strong>Eingabe: 3 14 31 7 29 10 18 15 19 0 x=10<br />
Fg enhält dann 14 31 29 18 15 19 und Fk 3 7 10<br />
Ausgabe: 14 3 31 7 29 10 18 15 19</strong></p>
<p>f array habe ich schon in fg und fk reingeschrieben, aber wie ich nacheinander ausgebe komme ich nicht dazu. Ich bin im Moment beim Stof array , zeiger</p>
<p>danke euch nata</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237580</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237580</guid><dc:creator><![CDATA[nata]]></dc:creator><pubDate>Wed, 01 Aug 2012 11:54:37 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:05:08 GMT]]></title><description><![CDATA[<p>schreib mal ein bisschen mehr... ich habe zwar so eine Ahnung, wie die Aufgabe sein soll, aber irgendwie wäre mehr Text wirklich hilfreich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237582</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:05:08 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:07:45 GMT]]></title><description><![CDATA[<p>oooo danke</p>
<p><strong>Lesen Sie maximal 50 Zahlen (Abschluß mit 0) in ein Feld F ein, sowie einen Wert x. Teilen Sie den Inhalt des Feldes F so auf zwei weitere Felder Fg und Fk auf, dass alle Werte, die größer als x sind, in Fg liegen und alle anderen in Fk.<br />
Geben Sie dann abwechselnd je eine Zahl aus Fg und eine aus Fk aus, solange bis alle Zahlen ausgegeben sind.</strong></p>
<p>mein code</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
using namespace std;

int main(){

	const int max = 50;
	int fg[max];
	int fk[max];
	int f[max];
	int zahl_eingeben = 0;
	int x;
	int neu = 1;
	int klein = 0;
	int gross = 0;

	while(neu != 0){

		cin &gt;&gt; neu;
		if(zahl_eingeben &lt; max &amp;&amp; neu !=0){
			f[zahl_eingeben] = neu;
			zahl_eingeben +=1;

		}
	}

	cin &gt;&gt; x;

	for(int i = 0; i &lt; zahl_eingeben; i++){
		if(f[i] &gt; x){
			fg[gross] = f[i];
			gross +=1;
		}else{
			fk[klein] = f[i];
			klein += 1;
		}

	}

	cout &lt;&lt; &quot;Array mit kleine Zahle ist :\n&quot;;
	for(int i = 0; i &lt; klein; i++){
		cout &lt;&lt; fk[i] &lt;&lt; &quot; &quot; ;
	}

	cout &lt;&lt; endl;

	cout &lt;&lt; &quot;Array mit große Zahle ist :\n&quot;;
	for(int i = 0; i &lt; gross; i++){
		cout &lt;&lt; fg[i] &lt;&lt; &quot; &quot; ;
	}

	cout &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>lg nata</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237585</guid><dc:creator><![CDATA[nata]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:07:45 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:16:27 GMT]]></title><description><![CDATA[<p>Du brauchst die Arrays nicht zu verschmelzen, einfach nur abwechselnd in <strong>einer</strong> Schleife ausgeben und natürlich vor der Ausgabe prüfen, ob sich eine Zahl im Array befindet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237588</guid><dc:creator><![CDATA[schmelz0r]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:16:27 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:17:12 GMT]]></title><description><![CDATA[<p>Hallo nata,</p>
<p>ich nehme an, dass Du damit</p>
<pre><code class="language-cpp">#include &lt;iterator&gt;
#include &lt;iostream&gt;

template&lt; typename I1, typename I2, typename O &gt;
void reissverschluss( I1 first1, I1 last1, I2 first2, I2 last2, O out )
{
    for( ; first1 != last1 || first2 != last2; )
    {
        if( first1 != last1 )
            *out++ = *first1++;
        if( first2 != last2 )
            *out++ = *first2++;
    }
}

int main()
{
    using namespace std;
    int fg[] = { 14, 31, 29, 18, 15, 19 };
    int fk[] = { 3, 7, 10 };
    reissverschluss( fg, fg + sizeof(fg)/sizeof(*fg), fk, fk + sizeof(fk)/sizeof(*fk), ostream_iterator&lt; int &gt;( cout &lt;&lt; &quot;Ausgabe &quot;, &quot; &quot; ) );
    cout &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>nicht viel anfangen kannst. Das mit den Arrays ist irgendwie umständlich. Ständig muss man sich um das Ende des Arrays kümmern.</p>
<p>Das Programm oben erzeugt</p>
<pre><code>Ausgabe 14 3 31 7 29 10 18 15 19
</code></pre>
<p>poste mal den Code, der fg und fk beschreibt. ... Ah - da ist er ja schon.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237589</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:17:12 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:21:59 GMT]]></title><description><![CDATA[<p>ich muss doch abwechselnd ausgeben. zuerst habe ich mir überleft, dass ich das mit 2 for schleifen mache, aber es hat kein sinn</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7393">@werner</a>: danke werner für dein Code, aber es ist für mich kompliziert. ich lerne schritt für schritt und schaue dass ich möglichst viele codes schreibe, damit ich im oktober auf der prüfung kein probleme habe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237592</guid><dc:creator><![CDATA[nata]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:21:59 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:21:52 GMT]]></title><description><![CDATA[<p>nata schrieb:</p>
<blockquote>
<p>ich muss doch abwechselnd ausgeben. zuerst habe ich mir überleft, dass ich das mit 2 for schleifen mache, aber es hat kein sinn</p>
</blockquote>
<p>eine schleife reicht. ich würde für die aufteilung der zahlen zwei zählvariable spendieren, damit das programm für die ausgabe weiß, wieviele zahlen jeweils in den arrays sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237595</guid><dc:creator><![CDATA[schmelz0r]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:21:52 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:33:22 GMT]]></title><description><![CDATA[<p>Wasn das für ´ne beknackte Aufgabe? Was passiert denn für die Eingaben</p>
<pre><code>1 2 3 4 5 6 7 8 9 10
</code></pre>
<p>und</p>
<pre><code>x = 25
</code></pre>
<p>?</p>
<p>Ansonsten kriegt man das Ganze relativ einfach mit <code>std::vector</code> , <code>std::partition</code> und <code>std::greater</code> hin. Einfach alle Werte in den Vektor einlesen, <code>std::partition</code> mit dem Prädikat <code>std::greater&lt;int&gt;( x )</code> aufrufen und die Werte ausgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237604</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:33:22 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:36:58 GMT]]></title><description><![CDATA[<p>in klein und gross ist doch die größe der jeweiligen arrays gespeichert</p>
<p>meinst du dass ich so machen soll:</p>
<pre><code class="language-cpp">if(gross &gt; klein){
         //for schleife wo ich gross durchlaufe
     }else{
            //for schlefe wo ich klein durchlaufe
         }
</code></pre>
<p>in meinem fall weiß ich schon dass gross mehr ist habe so gemacht</p>
<pre><code class="language-cpp">for(int i = 0; i &lt; gross; i++){
		cout &lt;&lt; fg[i] &lt;&lt; &quot; &quot; &lt;&lt; fk[i];
	}
</code></pre>
<p>aber ausgabe war <strong>14 331 729 1018 3276715 494119 -844248416</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237606</guid><dc:creator><![CDATA[nata]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:36:58 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:39:35 GMT]]></title><description><![CDATA[<p>DocShoe schrieb:</p>
<blockquote>
<p>Wasn das für ´ne beknackte Aufgabe? Was passiert denn für die Eingaben</p>
<pre><code>1 2 3 4 5 6 7 8 9 10
</code></pre>
<p>und</p>
<pre><code>x = 25
</code></pre>
<p>?</p>
<p>Ansonsten kriegt man das Ganze relativ einfach mit <code>std::vector</code> , <code>std::partition</code> und <code>std::greater</code> hin. Einfach alle Werte in den Vektor einlesen, <code>std::partition</code> mit dem Prädikat <code>std::greater&lt;int&gt;( x )</code> aufrufen und die Werte ausgeben.</p>
</blockquote>
<p>dann passiert bei korrekter implemetierung das:</p>
<blockquote>
<p>ausgabe:</p>
<p>Fg:<br />
Fk: 1 2 3 4 5 6 7 8 9 10</p>
</blockquote>
<p>nata schrieb:</p>
<blockquote>
<p>in klein und gross ist doch die größe der jeweiligen arrays gespeichert</p>
</blockquote>
<p>okay, das ist gut. später kannst dann vektoren benutzen, dann kannst du die zählvariable sparen, also weglassen.<br />
<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/2237609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237609</guid><dc:creator><![CDATA[schmelz0r]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:39:35 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:43:25 GMT]]></title><description><![CDATA[<p>[quote=&quot;nata&quot;]<br />
meinst du dass ich so machen soll:</p>
<pre><code class="language-cpp">if(gross &gt; klein){
         //for schleife wo ich gross durchlaufe
     }else{
            //for schlefe wo ich klein durchlaufe
         }
</code></pre>
<p>nein, eher so:</p>
<p>for (i=0; i&lt;zahl_eingebe; i++)<br />
{<br />
if ( i&lt;klein ) cout &lt;&lt; fk[i] ....<br />
if ( i&lt;gross ) cout &lt;&lt; fg[i] ....</p>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237610</guid><dc:creator><![CDATA[schmelz0r]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:43:25 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:53:10 GMT]]></title><description><![CDATA[<p>wahnsinn. es funktioniert, aber als ich den codeteil gelesen habe, habe nicht geglaubt dass es funktionieren konnte <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>
<p>aber als ich groß durchgelaufen bin und cout &lt;&lt; fg[i] &lt;&lt; &quot; &quot; &lt;&lt; fk[i];<br />
ausgegeben habe,warum war so komische ausgabe?</p>
<p>danke nochmals</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237615</guid><dc:creator><![CDATA[nata]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:53:10 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 12:52:24 GMT]]></title><description><![CDATA[<p>büddää, null problemooooo<br />
<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/2237618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237618</guid><dc:creator><![CDATA[schmelz0r]]></dc:creator><pubDate>Wed, 01 Aug 2012 12:52:24 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 13:16:50 GMT]]></title><description><![CDATA[<p>nata schrieb:</p>
<blockquote>
<p>aber als ich groß durchgelaufen bin und cout &lt;&lt; fg[i] &lt;&lt; &quot; &quot; &lt;&lt; fk[i];<br />
ausgegeben habe,warum war so komische ausgabe?</p>
</blockquote>
<p>weil du 2 zahlen mit einem leerzeichen dazwischen ausgegeben hast (-&gt; &quot;5 87&quot;) und im nächsten schleifen durchlauf das gleiche wieder gemacht hast ohne trennzeichen(-&gt; &quot;5 87&quot; + &quot;2 67&quot; ==&gt; &quot;5 872 67&quot;)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237623</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Wed, 01 Aug 2012 13:16:50 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 13:21:59 GMT]]></title><description><![CDATA[<p>nata schrieb:</p>
<blockquote>
<p>aber als ich groß durchgelaufen bin und cout &lt;&lt; fg[i] &lt;&lt; &quot; &quot; &lt;&lt; fk[i];</p>
</blockquote>
<p>das funktioniert auch nur, wenn die Arrays gleich groß sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237626</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237626</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Wed, 01 Aug 2012 13:21:59 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann man 2 Array verschmelzen? on Wed, 01 Aug 2012 13:39:28 GMT]]></title><description><![CDATA[<p>sind sie ja, aber sie sind nicht unbedingt komplett gefüllt mit richtigen daten, sprich ab einem gewissen index könnte schmuh rauskommen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237630</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Wed, 01 Aug 2012 13:39:28 GMT</pubDate></item></channel></rss>