<?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[Dualzahl in Binärzahl in Array]]></title><description><![CDATA[<p>Ich möchte eine Dualzahl in eine Binärzahl umwandeln. Dies ist ist auch gar keine Problem, und ich konnte es auch lösen. Nun habe ich jede einzlene Ziffer der Binärzahl in ein Array geschrieben. Nun beim auslesen, muss ich natürlich eine for-Schleife machen, welche mir jede einzelne Position des Arrays ausgibt. Nun möchte ich jedioch, dass ich nur noch etwas augebenen muss (String?). Ich habe schon versucht die einzlene Position in mit gets (txt) als String zu machen, leider ohne erfolg. Gibt es hier überhaupt eine Möglichkeit dies anderst auszugben?</p>
<p>Hier mein bisheriger Code:<br />
[/cpp]<br />
#include &quot;stdafx.h&quot;<br />
#include &lt;iostream&gt;<br />
#include &lt;conio.h&gt;</p>
<p>using namespace std;</p>
<p>int Dualzahl [15];</p>
<p>void main()<br />
{<br />
int zahl,rest;</p>
<p>cout &lt;&lt; &quot;Eingabe der Zahl: &quot;; cin &gt;&gt; zahl;</p>
<p>do<br />
{<br />
for (int i=0; i&lt;=14; i++)<br />
{<br />
rest=zahl%2;<br />
Dualzahl[i]=rest;<br />
zahl=zahl/2;<br />
}<br />
}</p>
<p>while (zahl&gt;0);<br />
for (int i=14; i&gt;=0; i--)<br />
{<br />
cout &lt;&lt; Dualzahl[i];<br />
}</p>
<p>char ch=getch ();</p>
<p>}<br />
[cpp]<br />
Vielen Dank im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/309394/dualzahl-in-binärzahl-in-array</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 06:36:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309394.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Oct 2012 09:19:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 09:19:18 GMT]]></title><description><![CDATA[<p>Ich möchte eine Dualzahl in eine Binärzahl umwandeln. Dies ist ist auch gar keine Problem, und ich konnte es auch lösen. Nun habe ich jede einzlene Ziffer der Binärzahl in ein Array geschrieben. Nun beim auslesen, muss ich natürlich eine for-Schleife machen, welche mir jede einzelne Position des Arrays ausgibt. Nun möchte ich jedioch, dass ich nur noch etwas augebenen muss (String?). Ich habe schon versucht die einzlene Position in mit gets (txt) als String zu machen, leider ohne erfolg. Gibt es hier überhaupt eine Möglichkeit dies anderst auszugben?</p>
<p>Hier mein bisheriger Code:<br />
[/cpp]<br />
#include &quot;stdafx.h&quot;<br />
#include &lt;iostream&gt;<br />
#include &lt;conio.h&gt;</p>
<p>using namespace std;</p>
<p>int Dualzahl [15];</p>
<p>void main()<br />
{<br />
int zahl,rest;</p>
<p>cout &lt;&lt; &quot;Eingabe der Zahl: &quot;; cin &gt;&gt; zahl;</p>
<p>do<br />
{<br />
for (int i=0; i&lt;=14; i++)<br />
{<br />
rest=zahl%2;<br />
Dualzahl[i]=rest;<br />
zahl=zahl/2;<br />
}<br />
}</p>
<p>while (zahl&gt;0);<br />
for (int i=14; i&gt;=0; i--)<br />
{<br />
cout &lt;&lt; Dualzahl[i];<br />
}</p>
<p>char ch=getch ();</p>
<p>}<br />
[cpp]<br />
Vielen Dank im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262752</guid><dc:creator><![CDATA[evo-style]]></dc:creator><pubDate>Mon, 22 Oct 2012 09:19:18 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 09:20:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::vector&lt;int&gt; Dualzahl;

// ...

cout &lt;&lt; Dualzahl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2262754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262754</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Mon, 22 Oct 2012 09:20:55 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 09:45:32 GMT]]></title><description><![CDATA[<p>Wie muss ich das einbinden? Ist das ein eigenständiger Befehl, welcher meine Berechnung gar nicht braucht?</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262768</guid><dc:creator><![CDATA[evo-style]]></dc:creator><pubDate>Mon, 22 Oct 2012 09:45:32 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 10:06:42 GMT]]></title><description><![CDATA[<p>Schau mal hier: <a href="http://www.cplusplus.com/reference/stl/vector/" rel="nofollow">http://www.cplusplus.com/reference/stl/vector/</a></p>
<p>Hier ein Beispiel:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;
using namespace std;

int main()
{
int zahl,rest;
vector&lt;int&gt; Dualzahl;

cout &lt;&lt; &quot;Eingabe der Zahl: &quot;;
cin &gt;&gt; zahl;

do
{
         rest=zahl%2;
         Dualzahl.push_back(rest);
         zahl=zahl/2;
}
while (zahl&gt;0);

 for(int i=Dualzahl.size()-1;i&gt;=0;i--)
 {
        cout&lt;&lt;Dualzahl[i];
 }

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2262773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262773</guid><dc:creator><![CDATA[Bassmaster]]></dc:creator><pubDate>Mon, 22 Oct 2012 10:06:42 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 10:33:16 GMT]]></title><description><![CDATA[<p>Ausgabe geht auch so:</p>
<pre><code class="language-cpp">std::copy(to_vector.begin(), to_vector.end(), 
              std::ostream_iterator&lt;int&gt;(std::cout, &quot;&quot;));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2262791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262791</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Mon, 22 Oct 2012 10:33:16 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 11:10:20 GMT]]></title><description><![CDATA[<p>Die Ausgabe in diesem Vector (dynamisches Array -&gt; sowieit ich verstanden habe!?) erfolgt ja dennoch über eine herunterzählende for-Schleife. Ich möchte jedoch die Ausgabe nicht in einer for-Schleife sondern die Binärezahl als ganzes ausgeben.<br />
Sprich:</p>
<p>cout &lt;&lt; Dualzahl;</p>
<p>(und nicht jede einzlene Position)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262811</guid><dc:creator><![CDATA[evo-style]]></dc:creator><pubDate>Mon, 22 Oct 2012 11:10:20 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 11:32:27 GMT]]></title><description><![CDATA[<p>evo-style schrieb:</p>
<blockquote>
<p>Ich möchte jedoch die Ausgabe nicht in einer for-Schleife sondern die Binärezahl als ganzes ausgeben.<br />
Sprich:</p>
<p>cout &lt;&lt; Dualzahl;</p>
<p>(und nicht jede einzlene Position)</p>
</blockquote>
<p>Dann brauchst du das Ganze wohl in einem std::string, oder du machst eine Operatorüberladung für std::vector&lt;int&gt;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262823</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Mon, 22 Oct 2012 11:32:27 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 11:36:03 GMT]]></title><description><![CDATA[<p>evo-style schrieb:</p>
<blockquote>
<p>Die Ausgabe in diesem Vector (dynamisches Array -&gt; sowieit ich verstanden habe!?) erfolgt ja dennoch über eine herunterzählende for-Schleife. Ich möchte jedoch die Ausgabe nicht in einer for-Schleife sondern die Binärezahl als ganzes ausgeben.<br />
Sprich:</p>
<p>cout &lt;&lt; Dualzahl;</p>
<p>(und nicht jede einzlene Position)</p>
</blockquote>
<p>Was stört dich an</p>
<p>daddy_felix schrieb:</p>
<blockquote>
<p>Ausgabe geht auch so:</p>
<pre><code class="language-cpp">std::copy(to_vector.begin(), to_vector.end(), 
              std::ostream_iterator&lt;int&gt;(std::cout, &quot;&quot;));
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2262825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262825</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Mon, 22 Oct 2012 11:36:03 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 11:39:57 GMT]]></title><description><![CDATA[<p>Hab ich erst jetzt gesehn, sorry. Muss mir dass noch genau anschauen. Da ich erlich gesagt nicht ganz Alles verstehe, und darum zum Teil auch nicht ganz genau weiss, wie man es einbinden muss...</p>
<p>Aber vielen Dank schonmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262830</guid><dc:creator><![CDATA[evo-style]]></dc:creator><pubDate>Mon, 22 Oct 2012 11:39:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 11:50:55 GMT]]></title><description><![CDATA[<p>ich empfehle dir, dass du erstmal in Ruhe std::vector ansiehst. Zum Einbinden brauchst du lediglich &quot;#include &lt;vector&gt;&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262834</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262834</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Mon, 22 Oct 2012 11:50:55 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 13:25:23 GMT]]></title><description><![CDATA[<p>Werde sehen ob ich was finde. Das Problem ist einfach, dass wir das in der Schule nie hatten. Und ich möglicherweise darum nicht dartauf gekommen bin. Desshlab wollte ich es auch in einen String reinpacken...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262867</guid><dc:creator><![CDATA[evo-style]]></dc:creator><pubDate>Mon, 22 Oct 2012 13:25:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dualzahl in Binärzahl in Array on Mon, 22 Oct 2012 17:58:16 GMT]]></title><description><![CDATA[<p>Habe Sachen über das std::vector angeschaut. Leider verstehe ich es nicht wirklich. Ist es nicht möglich einfach das Array in int=Dualzahl oder float oder so umzuwandeln?<br />
Da wird diese std:: leider auch nicht in der Schule hatten, habe ich leider keinerlei Unterlagen dazu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2262956</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2262956</guid><dc:creator><![CDATA[evo-style]]></dc:creator><pubDate>Mon, 22 Oct 2012 17:58:16 GMT</pubDate></item></channel></rss>