<?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[er ignoriert else]]></title><description><![CDATA[<p>Er ignoriert mein &quot;else&quot;, geht nicht in die 30 Tage Schleife, wo er nur bis 30 zählen soll. Was tun? Ich hab die ganze Nacht schon mit verschiedenen Klammern probiert.</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

int tz=1; //tageszähler
int mo=1;

int main () 
{

	for(int mo=1; mo&lt;13; mo=mo+1) //Monatszählerschleife
	{
		if (mo==1||3||5||7||8||10||12) //Tageszählerschleife für 31 Tage MONATE
			{
				for(int tz=1; tz&lt;32; tz=tz+1)
				{
				int Tag=Tag+ 1;
				cout&lt;&lt;&quot;Tag &quot; &lt;&lt;tz&lt;&lt;&quot; Monat &quot;&lt;&lt;mo&lt;&lt; &quot; \n&quot;;
				}
				cout&lt;&lt;&quot;MonatSENDE  \n  \n&quot;;
			}
			else
			{
					for(int tz=1; tz&lt;31; tz=tz+1) //Tageszählerschleife für 30 Tage
					{
					int Tag=Tag+1;
					cout&lt;&lt;&quot;Tag &quot; &lt;&lt;tz&lt;&lt;&quot; Monat &quot;&lt;&lt;mo&lt;&lt; &quot; \n&quot;;
					}
				cout&lt;&lt;&quot;Monatende  \n  \n&quot;;
			}	

	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/261200/er-ignoriert-else</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 14:24:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/261200.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Feb 2010 09:46:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 09:51:24 GMT]]></title><description><![CDATA[<p>Er ignoriert mein &quot;else&quot;, geht nicht in die 30 Tage Schleife, wo er nur bis 30 zählen soll. Was tun? Ich hab die ganze Nacht schon mit verschiedenen Klammern probiert.</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

int tz=1; //tageszähler
int mo=1;

int main () 
{

	for(int mo=1; mo&lt;13; mo=mo+1) //Monatszählerschleife
	{
		if (mo==1||3||5||7||8||10||12) //Tageszählerschleife für 31 Tage MONATE
			{
				for(int tz=1; tz&lt;32; tz=tz+1)
				{
				int Tag=Tag+ 1;
				cout&lt;&lt;&quot;Tag &quot; &lt;&lt;tz&lt;&lt;&quot; Monat &quot;&lt;&lt;mo&lt;&lt; &quot; \n&quot;;
				}
				cout&lt;&lt;&quot;MonatSENDE  \n  \n&quot;;
			}
			else
			{
					for(int tz=1; tz&lt;31; tz=tz+1) //Tageszählerschleife für 30 Tage
					{
					int Tag=Tag+1;
					cout&lt;&lt;&quot;Tag &quot; &lt;&lt;tz&lt;&lt;&quot; Monat &quot;&lt;&lt;mo&lt;&lt; &quot; \n&quot;;
					}
				cout&lt;&lt;&quot;Monatende  \n  \n&quot;;
			}	

	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1855779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855779</guid><dc:creator><![CDATA[Bekell]]></dc:creator><pubDate>Mon, 15 Feb 2010 09:51:24 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 09:51:51 GMT]]></title><description><![CDATA[<p>Was erwartest du hiervon?</p>
<pre><code class="language-cpp">if (mo==1||3||5||7||8||10||12)
</code></pre>
<p>Tipp:<br />
Integer werden wenn nötig als bool interpretiert. Dabei ist 0 == false, ansonsten true.<br />
Also ist 3 true, und 5, und 7, und ...<br />
Deshalb ist dein if-Statement IMMER true!</p>
<p>// edit:<br />
Deiner Einrückung verwirrt...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855783</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855783</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Mon, 15 Feb 2010 09:51:51 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 09:52:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if(mo==1 || mo == 3 || mo == 5 || ...)
</code></pre>
<p>So hat das auszusehen. Leider gibt es auch keinen IN-Operator für solcherlei Zwecke.</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855785</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Mon, 15 Feb 2010 09:52:51 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 09:54:09 GMT]]></title><description><![CDATA[<pre><code>if(mo ==1 || mo == 3 || mo == 5) //usw. die andern noch ergänzen
</code></pre>
<p>muss man das nicht so schreiben?</p>
<p>edith sagt: SideWinder war schneller <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/1855786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855786</guid><dc:creator><![CDATA[Keithy]]></dc:creator><pubDate>Mon, 15 Feb 2010 09:54:09 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 09:56:39 GMT]]></title><description><![CDATA[<p>Ich will einfach, wenn der Monatszähler auf Juni steht, daß er zum 30 Tagezähler geht, wenn er auf Januar steht, soll er zum 31 Tage Zähler gehen. Das kann doch nicht so schwer sein.</p>
<p>Was für ein Ausdruck muß denn in die Bedingung rein?</p>
<p>DANKE DANKE DANKE, klappt alles</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855787</guid><dc:creator><![CDATA[Bekell]]></dc:creator><pubDate>Mon, 15 Feb 2010 09:56:39 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 10:00:39 GMT]]></title><description><![CDATA[<p>Ich bezweifle dass es klappt! Schau mal aktuell auf nen Kalender!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855792</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Mon, 15 Feb 2010 10:00:39 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 10:08:23 GMT]]></title><description><![CDATA[<p>l'abra d'or schrieb:</p>
<blockquote>
<p>Ich bezweifle dass es klappt! Schau mal aktuell auf nen Kalender!</p>
</blockquote>
<p>nun gib ihm schon den zaunpfahl-tipp <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>mach einen else-if-zweig für den Februar (28)<br />
edith: wenn mans ganz genau nehmen will, füge man noch die Schaltjahre mit dem 29-Tage-Februar ein..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855796</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855796</guid><dc:creator><![CDATA[Keithy]]></dc:creator><pubDate>Mon, 15 Feb 2010 10:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to er ignoriert else on Mon, 15 Feb 2010 11:01:43 GMT]]></title><description><![CDATA[<p>Was hälst du von einem Array mit der Anzahl der Tage je Monat?</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

unsigned int DayCount[] = { 31, 28, 31, 30, 31, 30, 
                            31, 31, 30, 31, 30, 31 };

using namespace std;
int main()
{
   for( unsigned int Month = 0; Month &lt; 12; ++Month )
   {  
      for( unsigned int Day = 0; Day &lt; DayCount[Month]; ++Day )
      {
         cout &lt;&lt; &quot;Tag  : &quot; &lt;&lt; Day &lt;&lt; 
              &lt;&lt; &quot;Monat: &quot; &lt;&lt; Month &lt;&lt; endl;
      }
   }
}
</code></pre>
<p>Btw: Wofür brauchst du die globalen Variablen mo und tz? Und wofür die lokale Variable Tag?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855828</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Mon, 15 Feb 2010 11:01:43 GMT</pubDate></item></channel></rss>