<?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[Befehl &amp;quot;case&amp;quot;]]></title><description><![CDATA[<p>Guten Abend</p>
<p>ich habe hier ein frage zu dem befehl Case. kann man darin mehrere Regeln einfügen? z.B.<br />
schreib ein c++ programm, welches dir bei der note 90-100 &quot;sehr gut&quot; schreibt<br />
bei 80-89 gut bei 70-79 befriedigend usw.</p>
<p>hier mein erster ansatz. aber leider klappt es nicht.<br />
ich benutze visual basic 6.0</p>
<pre><code># include &lt;iostream.h&gt;
void main ()
{   int x;
cin &gt;&gt; x;
switch (x)
{case (x&gt;=90) : cout &lt;&lt; &quot;sehr gut&quot;;
break ;
case (x&gt;=80 &amp;&amp; x&lt;90) : cout &lt;&lt; &quot;gut&quot;;
	break;
case ( x&gt;=70 &amp;&amp; x&lt;80) : cout &lt;&lt; &quot;befriedigend&quot;;
	break;
default : cout &lt;&lt;&quot;failed&quot;;
}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/299544/befehl-quot-case-quot</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 03:29:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/299544.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Feb 2012 15:31:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Mon, 13 Feb 2012 15:31:05 GMT]]></title><description><![CDATA[<p>Guten Abend</p>
<p>ich habe hier ein frage zu dem befehl Case. kann man darin mehrere Regeln einfügen? z.B.<br />
schreib ein c++ programm, welches dir bei der note 90-100 &quot;sehr gut&quot; schreibt<br />
bei 80-89 gut bei 70-79 befriedigend usw.</p>
<p>hier mein erster ansatz. aber leider klappt es nicht.<br />
ich benutze visual basic 6.0</p>
<pre><code># include &lt;iostream.h&gt;
void main ()
{   int x;
cin &gt;&gt; x;
switch (x)
{case (x&gt;=90) : cout &lt;&lt; &quot;sehr gut&quot;;
break ;
case (x&gt;=80 &amp;&amp; x&lt;90) : cout &lt;&lt; &quot;gut&quot;;
	break;
case ( x&gt;=70 &amp;&amp; x&lt;80) : cout &lt;&lt; &quot;befriedigend&quot;;
	break;
default : cout &lt;&lt;&quot;failed&quot;;
}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2180558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180558</guid><dc:creator><![CDATA[Mohamedyarub]]></dc:creator><pubDate>Mon, 13 Feb 2012 15:31:05 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Mon, 13 Feb 2012 15:42:17 GMT]]></title><description><![CDATA[<p>Mohamedyarub schrieb:</p>
<blockquote>
<p>ich habe hier ein frage zu dem befehl Case. kann man darin mehrere Regeln einfügen?</p>
</blockquote>
<p>Es gibt keinen case-Befehl, du meinst die switch-Anweisung. Ja, dort kann man mehrere case-Zweige angeben. Das sind aber keine Regeln.</p>
<blockquote>
<p>z.B.<br />
schreib ein c++ programm, welches dir bei der note 90-100 &quot;sehr gut&quot; schreibt<br />
bei 80-89 gut bei 70-79 befriedigend usw.</p>
</blockquote>
<p>Würde ich mit einer if-else-Kette machen:</p>
<pre><code class="language-cpp">if (note &gt;= 90 &amp;&amp; note &lt;= 100) ...
else if (note &gt;= 80 &amp;&amp; note &lt;= 89) ...
else usw....
</code></pre>
<blockquote>
<p>ich benutze visual basic 6.0</p>
</blockquote>
<p>Schön für dich, was tut das zur Sache? Ein Ratespiel, du benutzt also vermutlich auch Visual C++ 6.0?</p>
<p>Zu deinem Code:</p>
<blockquote>
<pre><code># include &lt;iostream.h&gt; // &lt;- &lt;iostream&gt; heißt das heutzutage
                             // using namespace std; wär auch nicht schlecht für cout usw.
void main ()                 // int main() bitte
{   int x;
cin &gt;&gt; x;
switch (x)
{case (x&gt;=90) : cout &lt;&lt; &quot;sehr gut&quot;; // case-Labels müssen Konstanten sein, also z.B. case 90:
break ;
case (x&gt;=80 &amp;&amp; x&lt;90) : cout &lt;&lt; &quot;gut&quot;;
	break;
case ( x&gt;=70 &amp;&amp; x&lt;80) : cout &lt;&lt; &quot;befriedigend&quot;;
	break;
default : cout &lt;&lt;&quot;failed&quot;;
}
}
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2180569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180569</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Mon, 13 Feb 2012 15:42:17 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Mon, 13 Feb 2012 15:51:37 GMT]]></title><description><![CDATA[<p>erst einmal vielen dank für deine schnelle antwort</p>
<blockquote>
<p>ich benutze visual basic 6.0</p>
<p>Schön für dich, was tut das zur Sache? Ein Ratespiel, du benutzt also vermutlich auch Visual C++ 6.0?</p>
</blockquote>
<p>tut mir leid aber ich hab das nur gesagt, damit ihr wisst, welches programm ich benutze. ich hatte vor ein paar monaten Turbo c++ verwendet und da ist die schreibweise des programms anderes. also nichts für ungut.</p>
<p>ja mit if else kann ich es machen. aber es wird von mir verlangt, dass ich es mit switch mache.</p>
<blockquote>
<p>case-Labels müssen Konstanten sein, also z.B. case 90:</p>
</blockquote>
<p>aber man kann auch regeln einfügen wie z.B x&gt;0 oder x&lt;0 bei negativen und positiven zahlen.</p>
<p>ich hoffe ihr könnt mir jetzt weiterhelfen.</p>
<p>vielen dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180578</guid><dc:creator><![CDATA[Mohamedyarub]]></dc:creator><pubDate>Mon, 13 Feb 2012 15:51:37 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Mon, 13 Feb 2012 15:59:53 GMT]]></title><description><![CDATA[<p>Mohamedyarub schrieb:</p>
<blockquote>
<blockquote>
<p>ich benutze visual basic 6.0</p>
<p>Schön für dich, was tut das zur Sache? Ein Ratespiel, du benutzt also vermutlich auch Visual C++ 6.0?</p>
</blockquote>
<p>tut mir leid aber ich hab das nur gesagt, damit ihr wisst, welches programm ich benutze.</p>
</blockquote>
<p>Das Programm heißt aber Visual Studio, der C++-Compiler dazu heißt Visual C++. Visual Basic ist eine andere Programmiersprache, die auch zum Visual Studio gehört.</p>
<blockquote>
<p>ja mit if else kann ich es machen. aber es wird von mir verlangt, dass ich es mit switch mache.</p>
</blockquote>
<p>Dann wird es ziemlich umständlich:</p>
<pre><code class="language-cpp">switch (x) {
  case 80:
  case 81:
  case 82:
  ...
  case 89: cout &lt;&lt; &quot;Gut&quot;; break;
  case 90:
  case 91:
  case 92:
  ...
  case 100: cout &lt;&lt; &quot;Sehr gut&quot;; break;
  ...
}
</code></pre>
<blockquote>
<blockquote>
<p>case-Labels müssen Konstanten sein, also z.B. case 90:</p>
</blockquote>
<p>aber man kann auch regeln einfügen wie z.B x&gt;0 oder x&lt;0 bei negativen und positiven zahlen.</p>
</blockquote>
<p>Nein, kann man nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180586</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Mon, 13 Feb 2012 15:59:53 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Mon, 13 Feb 2012 16:12:55 GMT]]></title><description><![CDATA[<p>stimmt du hast vollommen recht. man kann echt nur konstante einfügen in case<br />
aber warum hat mein lehrer gesagt, dass sowas geht?</p>
<pre><code># include &lt;iostream.h&gt;
void main ()
{
	int n;
	cin &gt;&gt; n;
	switch (n)
	{case (n&gt;0) : cout &lt;&lt;&quot; die nummer ist positive&quot;;
	break ;
	case (n=0) : cout &lt;&lt; die nummer ist null&quot;;
				   break;
	default: cout &lt;&lt; &quot;die nummer ist negative&quot;;
	}
}
</code></pre>
<p>ok dann muss ich es mit if else machen. weil ich werde keine 100 case befehle schreiben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180595</guid><dc:creator><![CDATA[Mohamedyarub]]></dc:creator><pubDate>Mon, 13 Feb 2012 16:12:55 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Mon, 13 Feb 2012 16:36:57 GMT]]></title><description><![CDATA[<p>Mohamedyarub schrieb:</p>
<blockquote>
<p>stimmt du hast vollommen recht. man kann echt nur konstante einfügen in case<br />
aber warum hat mein lehrer gesagt, dass sowas geht?</p>
</blockquote>
<p>Vielleicht weil er das von Visual Basic so kennt und bei C++ verwirrt ist? Jedenfalls würde ich dem, was der so sagt, nicht unbedingt viel Vertrauen entgegenbringen. Das mit dem <code>void main()</code> oder <code>iostream.h</code> ist wie gesagt Käse bzw. stark veraltet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180614</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Mon, 13 Feb 2012 16:36:57 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Wed, 15 Feb 2012 23:31:42 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<blockquote>
<p>ja mit if else kann ich es machen. aber es wird von mir verlangt, dass ich es mit switch mache.</p>
</blockquote>
<blockquote>
<p>aber man kann auch regeln einfügen wie z.B x&gt;0 oder x&lt;0 bei negativen und positiven zahlen.</p>
</blockquote>
<p>Nein, kann man nicht.</p>
</blockquote>
<p>Natürlich kann man. Mit C++ geht fast alles ...</p>
<pre><code class="language-cpp">int bedingung(int x)
{
  if(x&gt;=90) return 1;
  if((x&gt;=80) &amp;&amp; (x&lt;90)) return 2;
  if(x&lt;80) return 3;
} 

switch(bedingung(x))
  {
  case 1 : cout &lt;&lt; &quot;sehr gut&quot;; 
           break;   
  case 2 : cout &lt;&lt; &quot;gut&quot;; 
           break;   
  case 3 : cout &lt;&lt; &quot;befriedigend&quot;; 
           break;   
  default : cout &lt;&lt;&quot;failed&quot;;
  }
</code></pre>
<p>Alternativ könnte man statt Unterprogramm auch ein Makro verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181723</guid><dc:creator><![CDATA[merano]]></dc:creator><pubDate>Wed, 15 Feb 2012 23:31:42 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 06:43:48 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/u100590" rel="nofollow">Martin Richter</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/f1" rel="nofollow">MFC (Visual C++)</a> in das Forum <a href="http://www.c-plusplus.net/forum/f15" rel="nofollow">C++ (auch C++0x und C++11)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181755</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Thu, 16 Feb 2012 06:43:48 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 08:52:50 GMT]]></title><description><![CDATA[<p>Makros <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/2764.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--red_heart"
      title="&lt;3"
      alt="❤"
    /></p>
<p>Möglichkeit #1: Default-Case, keine durchfallenden Cases, Keine Blöcke um SWITCH möglich. Bsp.:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

#define SWITCH(expr) \
	for(bool __once_flag = true; __once_flag; __once_flag = false) \
		for(auto&amp;&amp; _ = expr; __once_flag; __once_flag = false) \
			if(false) \
				;

#define CASE(expr) else if(expr)
#define DEFAULT else

int main()
{
	int const i = 42;

	SWITCH(i)
		CASE(_ &lt; 42)
			std::cout &lt;&lt; &quot;'i' is less than '42'&quot;;

		CASE(_ &gt; 42)
			std::cout &lt;&lt; &quot;'i' is greater than '42'&quot;;

		DEFAULT
			std::cout &lt;&lt; &quot;'i' is equal to '42'&quot;;
}
</code></pre>
<p>Möglichkeit #2: Kein Default-Case, durchfallende Cases, wenn nachfolgenden Bedingungen wahr, Block um Switch erforderlich. Bsp.:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

#define SWITCH(expr) \
	for(bool __once_flag = true; __once_flag; __once_flag = false) \
		for(auto&amp;&amp; _ = expr; __once_flag; __once_flag = false)

#define CASE(expr) if(expr)

int main()
{
	int const i = 42;

	SWITCH(i)
	{
		CASE(_ &lt; 42)
		{
			std::cout &lt;&lt; &quot;'i' is less than '42'&quot;;
			break;
		}

		CASE(_ &gt; 42)
		{
			std::cout &lt;&lt; &quot;'i' is greater than '42'&quot;;
			break;
		}

		CASE(_ == 42)
		{
			std::cout &lt;&lt; &quot;'i' is equal to '42'&quot;;
			break;
		}
	}
}
</code></pre>
<p>&quot;_&quot; steht hier immer für das Argument, das dem SWITCH-Makro übergeben wurde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181777</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 16 Feb 2012 08:52:50 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 09:03:51 GMT]]></title><description><![CDATA[<p>Pi, wem genau soll das jetzt helfen? Genau, absolut niemandem. Der Lehrer wird meckern, weil er es ganz anders haben wollte. Und weil er mit dem VC6-Compiler deinen neumodischen C++11-Müll nicht übersetzt kriegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181788</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 16 Feb 2012 09:03:51 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 09:06:33 GMT]]></title><description><![CDATA[<p>Muss immer alles irgendwem helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181789</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Thu, 16 Feb 2012 09:06:33 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 09:35:20 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Muss immer alles irgendwem helfen?</p>
</blockquote>
<p>In einem &quot;Ich brauche Hilfe&quot;-Thread? Am besten schon.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181800</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 16 Feb 2012 09:35:20 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 09:41:31 GMT]]></title><description><![CDATA[<p>Die Frage ist doch schon seit ein paar Tagen beantwortet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181804</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181804</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Thu, 16 Feb 2012 09:41:31 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 09:54:09 GMT]]></title><description><![CDATA[<p>Man könnte das alles mit modulo-operator und Massivzugriff ( Array, Vector usw ) machen.<br />
( Vorausgesetzt es ist so eine Aufgabe wie im Anfangspost ).<br />
so in der Art:</p>
<pre><code class="language-cpp">size_t index = static_cast&lt; size_t &gt;( note ) %  AnzahlDerElementen
std::cout &lt;&lt; ausgabe[ index  ];
</code></pre>
<p>Und sogar generell kann man anstatt vieler case-Anweisungen über einen Massivzugriff nachdenken ( auch wenn es nötig ist mit Funktionspointern )....<br />
So für die Zukunft...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181814</guid><dc:creator><![CDATA[Travor]]></dc:creator><pubDate>Thu, 16 Feb 2012 09:54:09 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 10:03:36 GMT]]></title><description><![CDATA[<p>Mohamedyarub schrieb:</p>
<blockquote>
<p>stimmt du hast vollommen recht. man kann echt nur konstante einfügen in case<br />
aber warum hat mein lehrer gesagt, dass sowas geht?</p>
</blockquote>
<p>Knallhart gesagt würde ich sagen, dass dein Lehrer von der switch Anweisung in C/C++ keine Ahnung hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181819</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181819</guid><dc:creator><![CDATA[Burkhi]]></dc:creator><pubDate>Thu, 16 Feb 2012 10:03:36 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 10:46:10 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Muss immer alles irgendwem helfen?</p>
</blockquote>
<p>In einem &quot;Ich brauche Hilfe&quot;-Thread? Am besten schon.</p>
</blockquote>
<p>Eigentlich schon ja.</p>
<p>Pi wollte eh nur wieder ein bisschen rumposen mit einem Makro Gefrickel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181835</guid><dc:creator><![CDATA[KiddieKenner]]></dc:creator><pubDate>Thu, 16 Feb 2012 10:46:10 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 12:04:03 GMT]]></title><description><![CDATA[<p>KiddieKenner schrieb:</p>
<blockquote>
<p>_matze schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Muss immer alles irgendwem helfen?</p>
</blockquote>
<p>In einem &quot;Ich brauche Hilfe&quot;-Thread? Am besten schon.</p>
</blockquote>
<p>Eigentlich schon ja.</p>
<p>Pi wollte eh nur wieder ein bisschen rumposen mit einem Makro Gefrickel.</p>
</blockquote>
<p>Blabla.<br />
Wenn die einzig korrekte Antwort auf den Thread wäre dass der Lehrer ne Niete ist, dann ist es okay die Sache etwas interessanter zu machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181878</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 16 Feb 2012 12:04:03 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 12:12:55 GMT]]></title><description><![CDATA[<p>Travor schrieb:</p>
<blockquote>
<p>Man könnte das alles mit modulo-operator und Massivzugriff ( Array, Vector usw ) machen.<br />
( Vorausgesetzt es ist so eine Aufgabe wie im Anfangspost ).<br />
...</p>
</blockquote>
<p>Wenn es wie in der Anfangsaufgabe immer 10er Blöcke sind, dann kann man auch einfach x durch 10 teilen und 10 cases nehmen.<br />
Passt wahrscheinlich eher zur Aufgabe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181888</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Thu, 16 Feb 2012 12:12:55 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 19:03:56 GMT]]></title><description><![CDATA[<p>Ok nach einigem Überlegen hab ich mal was zusammen gehackt was funktionieren könnte. Zugegeben keine elegante Lösung aber eine Lösung.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; // &lt;iostream.h&gt; bei aelteren compilern

using namespace std;

int main(int argc, char* argv[])
{
	unsigned int x;
	unsigned int y;

	cout &lt;&lt; endl &lt;&lt; &quot;Eingabe: &quot;;
	cin &gt;&gt; x;
	cout &lt;&lt; endl;

	y = x / 16; // wir haben nur 6 noten. 100 geteilt durch 6 ergibt 16.667 aber wir arbeiten der einfachheit halber hier nun mit 16

	switch(y)
	{
		case 0:
			cout &lt;&lt; &quot;ungenuegend&quot; &lt;&lt; endl;
			break;
		case 1:
			cout &lt;&lt; &quot;mangelhaft&quot; &lt;&lt; endl;
			break;
		case 2:
			cout &lt;&lt; &quot;ausreichend&quot; &lt;&lt; endl;
			break;
		case 3:
			cout &lt;&lt; &quot;befriedigend&quot; &lt;&lt; endl;
			break;
		case 4:
			cout &lt;&lt; &quot;gut&quot; &lt;&lt; endl;
			break;
		case 5:
			cout &lt;&lt; &quot;sehr gut&quot; &lt;&lt; endl;
			break;
		case 6:
			cout &lt;&lt; &quot;sehr gut&quot; &lt;&lt; endl;
			break;
		default:
			cout &lt;&lt; &quot;Fehler !!&quot; &lt;&lt; endl;
	}
	return 0;
}
</code></pre>
<p>Gruss Micha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2182044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182044</guid><dc:creator><![CDATA[Videonauth]]></dc:creator><pubDate>Thu, 16 Feb 2012 19:03:56 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 21:13:18 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<blockquote>
<p>Pi wollte eh nur wieder ein bisschen rumposen mit einem Makro Gefrickel.</p>
</blockquote>
<p>Blabla.<br />
Wenn die einzig korrekte Antwort auf den Thread wäre dass der Lehrer ne Niete ist, dann ist es okay die Sache etwas interessanter zu machen.</p>
</blockquote>
<p>Blabla.<br />
Wenn Pi wieder mal versucht einen auf dicke Hose zu machen, dann versucht Pi eben einen auf dicke Hose zu machen.<br />
Wieso willst du das schön reden?</p>
<p>Wobei mich sein gepose hier sogar weniger nervt, als dein Versuch es schönzureden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2182086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182086</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 16 Feb 2012 21:13:18 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Thu, 16 Feb 2012 22:02:42 GMT]]></title><description><![CDATA[<p>Ich weiß nicht, ob inzwischen der Switch-Block von VB anders funktioniert wie bei VB6 damals, aber es gab kein break und insofern war jeder neue Case-Block ein break des alten Blocks, also nicht wie in C++.</p>
<p>Was Makros angeht ist das Problem so billig, das diese den Code einfach unlesbar machen und totaler Overkill ist. Total unangebracht.</p>
<p>Jeder Programmierer checkt 6 Blöcke mit if-s am schnellsten, wobei auch hier wieder ein wenig Redundanzen beseitigen kann, die nur wieder zu Fehlern führen, wenn sich etwas ändert:</p>
<pre><code class="language-cpp">if(punkte &gt;=PUNKTE_NOTE1)
   note=1;
else if(punkte &gt;=PUNKTE_NOTE2) // &amp;&amp; punkte &lt; PUNKTE_NOTE1
   note=2;
else if(punkte &gt;=PUNKTE_NOTE3) // &amp;&amp; punkte &lt; PUNKTE_NOTE2
   note=3;
else if(punkte &gt;=PUNKTE_NOTE4) // &amp;&amp; punkte &lt; PUNKTE_NOTE3
   note=4;
else if(punkte &gt;=PUNKTE_NOTE5) // &amp;&amp; punkte &lt; PUNKTE_NOTE4
   note=5;
else
   note=6; // punkte &lt; PUNKTE_NOTE5
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2182110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182110</guid><dc:creator><![CDATA[PhilippHToner]]></dc:creator><pubDate>Thu, 16 Feb 2012 22:02:42 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Fri, 17 Feb 2012 09:51:47 GMT]]></title><description><![CDATA[<p>Ich würd's mit if/else implementieren und, weil der Lehrer sicherlich auch noch stur ist, aus nem Standard-Draft den Abschnitt zu möglichen Angaben nach case ausdrucken und ihm bei Bedarf hinknallen. Dann gibt's auch die 1,0 für zusätzliche Recherche.</p>
<p>Edit: Oder er fühlt sich angegriffen und gibt ihm dort (oder zukünftig) immer die schlechteste Note. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2182208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182208</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Fri, 17 Feb 2012 09:51:47 GMT</pubDate></item><item><title><![CDATA[Reply to Befehl &amp;quot;case&amp;quot; on Fri, 17 Feb 2012 09:59:22 GMT]]></title><description><![CDATA[<p>Am &quot;streberhaftesten&quot; wäre wohl, 2 Lösungen zu präsentieren. Eine nach Aufgabenstellung (mit 100 cases) und eine vernünftige, mit einer ordentlichen Erklärung, warum die switch-Variante in C++ für diese Aufgabe suboptimal ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2182214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182214</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Fri, 17 Feb 2012 09:59:22 GMT</pubDate></item></channel></rss>