<?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[Methode]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte gerne eine Methode schreiben die mir alle Primteiler einer Zahl zurück liefert und nur diese.</p>
<p>zb bei Zahl 12 hat die Primteiler 1 3;</p>
<p>Leider weis ich nicht genau wie ich das machen kann ....</p>
<p>Ich dachte an eine Forschleife die mir alle Teilergibt und eine weitere schleife testet ob es eine Primzahl ist wenn ja wird sie ausgeben...</p>
<p>aber das wirkt mir alles etwas zu groß für so eine kleine Methode.</p>
<p>danke im voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/313674/methode</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 03:54:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/313674.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Feb 2013 11:47:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 11:47:01 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte gerne eine Methode schreiben die mir alle Primteiler einer Zahl zurück liefert und nur diese.</p>
<p>zb bei Zahl 12 hat die Primteiler 1 3;</p>
<p>Leider weis ich nicht genau wie ich das machen kann ....</p>
<p>Ich dachte an eine Forschleife die mir alle Teilergibt und eine weitere schleife testet ob es eine Primzahl ist wenn ja wird sie ausgeben...</p>
<p>aber das wirkt mir alles etwas zu groß für so eine kleine Methode.</p>
<p>danke im voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2296718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296718</guid><dc:creator><![CDATA[Primpim]]></dc:creator><pubDate>Thu, 07 Feb 2013 11:47:01 GMT</pubDate></item><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 11:55:30 GMT]]></title><description><![CDATA[<blockquote>
<p>Primteiler</p>
</blockquote>
<p>Du meinst Primfaktoren.</p>
<blockquote>
<p>zb bei Zahl 12 hat die Primteiler 1 3</p>
</blockquote>
<p>1 ist keine Primzahl und die 2 fehlt.</p>
<p>Fang einfach an und wenn du Probleme hast, stelle konkrete Fragen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2296721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296721</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 07 Feb 2013 11:55:30 GMT</pubDate></item><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 11:55:43 GMT]]></title><description><![CDATA[<p>Primpim schrieb:</p>
<blockquote>
<p>ich möchte gerne eine Methode schreiben die mir alle Primteiler einer Zahl zurück liefert und nur diese.</p>
</blockquote>
<p>Du meinst sicherlich nur &quot;Funktion&quot; statt &quot;Methode&quot;. Den Begriff &quot;Methode&quot; benutzt man manchmal für spezielle Funktionen, die man nur &quot;auf einem Objekt&quot; aufrufen kann. Z.B. so: object.methode(3);</p>
<p>Primpim schrieb:</p>
<blockquote>
<p>zb bei Zahl 12 hat die Primteiler 1 3;</p>
</blockquote>
<p>Du meinst sicherlich 2 und 3.</p>
<p>Primpim schrieb:</p>
<blockquote>
<p>Ich dachte an eine Forschleife die mir alle Teilergibt und eine weitere schleife testet ob es eine Primzahl ist wenn ja wird sie ausgeben...</p>
</blockquote>
<p>Das klingt doch gut. Ich würde die aber empfehlen nicht alles in eine Funktion zu packen. Für das Teilproblem &quot;istPrimzahl&quot; bietet sich ja eine eigene Funktion an. Das macht das ganze auch und übersichtlicher und der Primzahltest wäre dann wiederverwendbat. Also so:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

bool istPrimzahl(long z)
{
  ...
}

void printPrimTeiler(long z)
{
  using namespace std;
  for ... {
    ...
    if (istPrimzahl(...)) {
      cout &lt;&lt; ... &lt;&lt; endl;
    }
    ...
  }
}

int main()
{
  printPrimTeiler(12);
}
</code></pre>
<p>Viel Spaß!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2296722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296722</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 07 Feb 2013 11:55:43 GMT</pubDate></item><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 12:13:31 GMT]]></title><description><![CDATA[<p>Das hier war mein Ansatz aber irgendwie gibt er mir da 8 mal -858993460 an...</p>
<pre><code>int main()
{

	int Zahl = 12;
	int Speicher[12];

	for(int i=1;i&lt;=Zahl;i++)
	{
		if (Zahl%i == 0)
		{
			for(int j = 0;i &lt;12;i++)
			{
			Speicher[j]= Zahl;
			cout&lt;&lt;Speicher[i]&lt;&lt;endl;
			}

		}

		else 
		{

		}

	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2296728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296728</guid><dc:creator><![CDATA[PrimPrim]]></dc:creator><pubDate>Thu, 07 Feb 2013 12:13:31 GMT</pubDate></item><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 13:12:46 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">for(int j = 0;i &lt;12;i++) { Speicher[j]= Zahl; ...
</code></pre>
<p>Du willst also die gleiche Zahl immer an die gleiche Stelle schreiben? Wohl kaum.</p>
<pre><code class="language-cpp">cout&lt;&lt;Speicher[i]&lt;&lt;endl
</code></pre>
<p>Hier gibst du dann nicht-initialisierte Werte aus. Also Bloedsinn. Dein Bloedsinn hat halt den Wert -858993460.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2296746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296746</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 07 Feb 2013 13:12:46 GMT</pubDate></item><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 13:26:35 GMT]]></title><description><![CDATA[<p>ja j++ hatte ich vergessen. und ausgabe j....<br />
aber dennoch funkst das ja nicht irgendwas habe ich falsch weis aber nicht was..<br />
würde mir evtl einer meinen code mal verbessern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2296755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296755</guid><dc:creator><![CDATA[PrimPrim]]></dc:creator><pubDate>Thu, 07 Feb 2013 13:26:35 GMT</pubDate></item><item><title><![CDATA[Reply to Methode on Thu, 07 Feb 2013 15:08:38 GMT]]></title><description><![CDATA[<p>Hast auch das i&lt;12 durch j&lt;12 ausgetauscht? Vielleicht postest du mal eine aktualisierte Variante.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2296815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2296815</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 07 Feb 2013 15:08:38 GMT</pubDate></item></channel></rss>