<?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[Problem bei zwei Programmen mit schleifen!?]]></title><description><![CDATA[<p>Hallo Gemeinde,</p>
<p>ich hab bei zwei Programmen die ich schreiben soll Probleme:</p>
<p>1.Zahl einlesen, umdrehen und in wörtern ausgeben. Soweit so gut es funktioniert das umddrehen und das ausgeben, aber zusammen funktionierts nicht <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>#include &lt;iostream&gt;<br />
using namespace std;<br />
int zahl,ziffer,umgedreht;</p>
<p>void main()<br />
{<br />
cout &lt;&lt; &quot;Geben sie eine ganze positive Zahl ein: &quot;;<br />
cin &gt;&gt; zahl;</p>
<p>while(zahl != 0)<br />
{</p>
<p>ziffer = zahl % 10;<br />
zahl = zahl / 10;<br />
umgedreht = umgedreht * 10 + ziffer;</p>
<p>}</p>
<p>switch(umgedreht)<br />
{<br />
case 0:<br />
cout &lt;&lt; &quot;Null&quot;;<br />
break;<br />
case 1:<br />
cout &lt;&lt; &quot;Eins&quot;;<br />
break;<br />
case 2:<br />
cout &lt;&lt; &quot;Zwei&quot;;<br />
break;<br />
case 3:<br />
cout &lt;&lt; &quot;Drei&quot;;<br />
break;<br />
case 4:<br />
cout &lt;&lt; &quot;Vier&quot;;<br />
break;<br />
case 5:<br />
cout &lt;&lt; &quot;Fuenf&quot;;<br />
break;<br />
case 6:<br />
cout &lt;&lt; &quot;Sechs&quot;;<br />
break;<br />
case 7:<br />
cout &lt;&lt; &quot;Sieben&quot;;<br />
break;<br />
case 8:<br />
cout &lt;&lt; &quot;Acht&quot;;<br />
break;<br />
case 9:<br />
cout &lt;&lt; &quot;Neun&quot;;<br />
break;<br />
}</p>
<p>}</p>
<p>2.Soll ich ein Prog schreiben das in einer Dauerschleife char Zeichen einliest. Wurde keine Ziffer (0,1,2,3,4,5,6,7,8 oder 9) eingegeben, soll die Eingabe wieder auf dem Bildschirm ausgegeben werden.Bei einem kleinen e wird die schleife beendet. Hier soll man den ascii Zeichensat beachten.</p>
<p>Hier steh ich absolut auf em Schlauch und hab gar keine Idee was ich machen soll.</p>
<p>Danke für eure Hilfe!!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/213107/problem-bei-zwei-programmen-mit-schleifen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 13:19:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/213107.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 May 2008 10:17:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:17:36 GMT]]></title><description><![CDATA[<p>Hallo Gemeinde,</p>
<p>ich hab bei zwei Programmen die ich schreiben soll Probleme:</p>
<p>1.Zahl einlesen, umdrehen und in wörtern ausgeben. Soweit so gut es funktioniert das umddrehen und das ausgeben, aber zusammen funktionierts nicht <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>#include &lt;iostream&gt;<br />
using namespace std;<br />
int zahl,ziffer,umgedreht;</p>
<p>void main()<br />
{<br />
cout &lt;&lt; &quot;Geben sie eine ganze positive Zahl ein: &quot;;<br />
cin &gt;&gt; zahl;</p>
<p>while(zahl != 0)<br />
{</p>
<p>ziffer = zahl % 10;<br />
zahl = zahl / 10;<br />
umgedreht = umgedreht * 10 + ziffer;</p>
<p>}</p>
<p>switch(umgedreht)<br />
{<br />
case 0:<br />
cout &lt;&lt; &quot;Null&quot;;<br />
break;<br />
case 1:<br />
cout &lt;&lt; &quot;Eins&quot;;<br />
break;<br />
case 2:<br />
cout &lt;&lt; &quot;Zwei&quot;;<br />
break;<br />
case 3:<br />
cout &lt;&lt; &quot;Drei&quot;;<br />
break;<br />
case 4:<br />
cout &lt;&lt; &quot;Vier&quot;;<br />
break;<br />
case 5:<br />
cout &lt;&lt; &quot;Fuenf&quot;;<br />
break;<br />
case 6:<br />
cout &lt;&lt; &quot;Sechs&quot;;<br />
break;<br />
case 7:<br />
cout &lt;&lt; &quot;Sieben&quot;;<br />
break;<br />
case 8:<br />
cout &lt;&lt; &quot;Acht&quot;;<br />
break;<br />
case 9:<br />
cout &lt;&lt; &quot;Neun&quot;;<br />
break;<br />
}</p>
<p>}</p>
<p>2.Soll ich ein Prog schreiben das in einer Dauerschleife char Zeichen einliest. Wurde keine Ziffer (0,1,2,3,4,5,6,7,8 oder 9) eingegeben, soll die Eingabe wieder auf dem Bildschirm ausgegeben werden.Bei einem kleinen e wird die schleife beendet. Hier soll man den ascii Zeichensat beachten.</p>
<p>Hier steh ich absolut auf em Schlauch und hab gar keine Idee was ich machen soll.</p>
<p>Danke für eure Hilfe!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508714</guid><dc:creator><![CDATA[Putzfrau]]></dc:creator><pubDate>Wed, 14 May 2008 10:17:36 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:29:00 GMT]]></title><description><![CDATA[<p>Zu deinem ersten Problem: Das switch so wie du es verwendest, funktioniert ja nur, wenn deine Zahl nur eine Ziffer hat. Du müsstest also (so ähnlich wie in deiner ersten Schleife) alle Ziffern deiner Zahl in einer Schleife durchlaufen. Wenn du selber auf die erste Schleife gekommen bist, wirst du das auch hinkriegen.</p>
<p>Zu deinem zweiten Problem: Wie überprüfst du denn, ob ein eingegebenes Zeichen nicht 0,1,2,3,4,5,6,7,8,9 ist? Stichwort <a href="http://de.wikipedia.org/wiki/Ascii" rel="nofollow">ASCII</a>. Bei einem 'e' abzubrechen ist auch nicht so schwer (Stichwort break).</p>
<p>EDIT: Ach ja, nach dem aktuellen Standard muss es int main() und nicht void main() heißen. Außerdem sind cpp-Tags (Beispiel:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main()
{
    cout &lt;&lt; &quot;Hello World&quot; &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>) und Einrückungen eine ganz nette Idee.</p>
<p>Felix</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508718</guid><dc:creator><![CDATA[Phoemuex]]></dc:creator><pubDate>Wed, 14 May 2008 10:29:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:31:24 GMT]]></title><description><![CDATA[<p>Zu 1:</p>
<pre><code class="language-cpp">static const char* numbers[] =
	{ &quot;Null&quot;, &quot;Eins&quot;, &quot;Zwei&quot;, &quot;Drei&quot;, &quot;Vier&quot;, &quot;Fuenf&quot;, &quot;Sechs&quot;, &quot;Sieben&quot;, &quot;Acht&quot;, &quot;Neun&quot; };

// ...

while(zahl != 0)
{

ziffer = zahl % 10;
zahl = zahl / 10;
umgedreht = umgedreht * 10 + ziffer;

	printf( &quot;%s &quot;, numbers[ ziffer ] );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1508722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508722</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 14 May 2008 10:31:24 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:31:54 GMT]]></title><description><![CDATA[<p>Ja das mit e ist natürlich nicht das Prob, aber wie kann ich den ASCII ins Programm einbinden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508723</guid><dc:creator><![CDATA[Putzfrau]]></dc:creator><pubDate>Wed, 14 May 2008 10:31:54 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:33:12 GMT]]></title><description><![CDATA[<p>Das mit den Einrückungen sieht bei mir eigentlich auch so aus. Beim Eintrag wurde die Formatierung aber irgendwie nicht übernommen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508724</guid><dc:creator><![CDATA[Putzfrau]]></dc:creator><pubDate>Wed, 14 May 2008 10:33:12 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:40:46 GMT]]></title><description><![CDATA[<p>Putzfrau schrieb:</p>
<blockquote>
<p>Das mit den Einrückungen sieht bei mir eigentlich auch so aus. Beim Eintrag wurde die Formatierung aber irgendwie nicht übernommen!</p>
</blockquote>
<p>Dann versuch doch mal rauszufinden, warum. Tipp: Es hat was damit zu tun dass der Code in den Beiträgen der anderen eingerahmt und bunt ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508730</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 14 May 2008 10:40:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:42:00 GMT]]></title><description><![CDATA[<p>Danke für den Tipp!</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10754">@David_pb</a> Danke aber soweit sind wir glaub noch nicht!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508731</guid><dc:creator><![CDATA[Putzfrau]]></dc:creator><pubDate>Wed, 14 May 2008 10:42:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 10:47:43 GMT]]></title><description><![CDATA[<p>So evtl.</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

int main()
{
    const char* numberLookup[] = {&quot;null&quot;, &quot;eins&quot;, &quot;zwei&quot;, &quot;drei&quot;, &quot;vier&quot;, &quot;fuenf&quot;, &quot;sechs&quot;, &quot;sieben&quot;, &quot;acht&quot;, &quot;neun&quot;};

    std::string input;
    std::string output;

    while(true)
    {
        std::cout &lt;&lt; &quot;Input&gt; &quot;;
        std::cin &gt;&gt; input;
        if(input == &quot;e&quot;)
        {
            break;
        }

        output = &quot;&quot;;
        for(std::string::reverse_iterator riter = input.rbegin(); riter != input.rend(); ++riter)
        {
            if(static_cast&lt;unsigned long&gt;(*riter - '0') &lt; 10)
            {
                output = output +  numberLookup[*riter - '0'] + ' ';
            }
            else
            {
                output = input;
                break;
            }
        }
        std::cout &lt;&lt; output &lt;&lt; '\n';
    }

    return EXIT_SUCCESS;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1508738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508738</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Wed, 14 May 2008 10:47:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:00:37 GMT]]></title><description><![CDATA[<p>Oder so:</p>
<pre><code class="language-cpp">static const char* numbers[] =
	{ &quot;null&quot;, &quot;eins&quot;, &quot;zwei&quot;, &quot;drei&quot;, &quot;vier&quot;, &quot;fuenf&quot;, &quot;sechs&quot;, &quot;sieben&quot;, &quot;acht&quot;, &quot;neun&quot;, &quot;unknown&quot; };

	std::string line;

	do
	{
		std::getline( std::cin, line );

		for( std::string::reverse_iterator it = line.rbegin(); it != line.rend(); ++it )
        {
			printf( &quot;%s &quot;, numbers[ std::isdigit( *it ) ? *it &amp; 0xf : 10 ] );
		}

	}  while ( line == &quot;e&quot; );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1508744</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508744</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 14 May 2008 11:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:04:08 GMT]]></title><description><![CDATA[<p>Hmm...</p>
<p>David_pb schrieb:</p>
<blockquote>
<pre><code class="language-cpp">while ( line == &quot;e&quot; );
</code></pre>
</blockquote>
<p>Hmm...</p>
<p>David_pb schrieb:</p>
<blockquote>
<pre><code class="language-cpp">printf(...)
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1508749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508749</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Wed, 14 May 2008 11:04:08 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:09:43 GMT]]></title><description><![CDATA[<p>Ups! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>So:</p>
<pre><code class="language-cpp">static const char* numbers[] =
	{ &quot;unknown&quot;, &quot;null&quot;, &quot;eins&quot;, &quot;zwei&quot;, &quot;drei&quot;, &quot;vier&quot;, &quot;fuenf&quot;, &quot;sechs&quot;, &quot;sieben&quot;, &quot;acht&quot;, &quot;neun&quot; };

	std::string line;

	while ( 1 )
	{
		std::getline( std::cin, line );

		if ( line == &quot;e&quot; )
			break;

		for( std::string::reverse_iterator it = line.rbegin(); it != line.rend(); ++it )
        {
			printf( &quot;%s &quot;, numbers[ bool( std::isdigit( *it ) ) * ( ( *it &amp; 0xf ) + 1 ) ] );
		}
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1508750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508750</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 14 May 2008 11:09:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:13:05 GMT]]></title><description><![CDATA[<p>Es ist nicht besser geworden:</p>
<pre><code class="language-cpp">while(1)
//...
printf( &quot;%s &quot;, numbers[ bool( std::isdigit( *it ) ) * ( ( *it &amp; 0xf ) + 1 ) ] );
</code></pre>
<p>Ausserdem sollte bei Falscheingabe die Eingabe ausgegeben werden und nicht unknown.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508753</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Wed, 14 May 2008 11:13:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:14:52 GMT]]></title><description><![CDATA[<p>Doch, ist besser geworden. Die Abbruchbedingung stimmt nämlich jetzt. Nur die Ausgabe nicht! <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/1508754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508754</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 14 May 2008 11:14:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:15:03 GMT]]></title><description><![CDATA[<p>Danke aber ihr macht das ganze hier viel zu professionell!?</p>
<p>eins hab ich jetzt. Gibts bei 2 einfach eine Möglichkeit, wie z.B.</p>
<p>while(a!='e')<br />
....</p>
<p>hier wird solang ausgeführt bis ein e eingegeben wird. Gibts sowas auch für die Zahlen, bzw. ASCII?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508755</guid><dc:creator><![CDATA[Putzfrau]]></dc:creator><pubDate>Wed, 14 May 2008 11:15:03 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:19:02 GMT]]></title><description><![CDATA[<p>Jadoch die Möglichkeit gibts:</p>
<pre><code class="language-cpp">char c;

	while ( true )
	{
		std::cin &gt;&gt; c;

		if ( c == 'e' )
			break;

		// tu irgendwas mit c
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1508757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508757</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 14 May 2008 11:19:02 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei zwei Programmen mit schleifen!? on Wed, 14 May 2008 11:38:17 GMT]]></title><description><![CDATA[<p>Ich glaube, dir ist nicht ganz klar, was das mit dem ASCII bedeutet. Du musst dafür nichts &quot;einbinden&quot;, oder so, intern werden die eingegebenen Zeichen (normalerweise) als ASCII codiert, d.h. 'e' entspricht zum Beispiel der Zahl 101 in Dezimal, bzw. 65 in Hexadezimaler schreibweise. Dadurch kannst du zum Beispiel prüfen, ob ein Zeichen, nennen wir es c 0,1,2,3,4,5,6,7,8,9 ist, indem du schreibst if('0' &lt;= c &amp;&amp; c &lt;= '9'), da die Ziffern im ASCII-Code &quot;hintereinander&quot; stehen.</p>
<p>Felix</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1508773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1508773</guid><dc:creator><![CDATA[Phoemuex]]></dc:creator><pubDate>Wed, 14 May 2008 11:38:17 GMT</pubDate></item></channel></rss>