<?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[Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases]]></title><description><![CDATA[<p>Habe vor einen Währungsrechner zu schreiben.</p>
<p>Wie bekommen ich es hin, dass ich aus 10 Währungen die sich jeweils x beliebig mal kombinieren lassen um sie auszurechnen so wenig Anweisungen wie möglich verwenden kann?</p>
<p>Gibt es nicht eine Art Selektion über Arrays... die das Programm wesentlich verkürzen.</p>
<p>Wäre interessiert an Programmiertechniken in dem Fall um Code zu sparen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/187912/währungsumrechner-ohne-x-viele-if-s-cases</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 01:28:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/187912.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jul 2007 12:13:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases on Wed, 25 Jul 2007 12:13:27 GMT]]></title><description><![CDATA[<p>Habe vor einen Währungsrechner zu schreiben.</p>
<p>Wie bekommen ich es hin, dass ich aus 10 Währungen die sich jeweils x beliebig mal kombinieren lassen um sie auszurechnen so wenig Anweisungen wie möglich verwenden kann?</p>
<p>Gibt es nicht eine Art Selektion über Arrays... die das Programm wesentlich verkürzen.</p>
<p>Wäre interessiert an Programmiertechniken in dem Fall um Code zu sparen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332247</guid><dc:creator><![CDATA[Kurz-und-knapp]]></dc:creator><pubDate>Wed, 25 Jul 2007 12:13:27 GMT</pubDate></item><item><title><![CDATA[Reply to Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases on Wed, 25 Jul 2007 12:16:51 GMT]]></title><description><![CDATA[<p>Du kannst ein Array (wenn du willst auch eine map&lt;&gt;) anlegen, in dem die Umrechnungskurse der jeweiligen Währungen nach Euro eingetragen sind. Dann mußt du nur noch Ursprungs- und Zielwährung auswählen (beim Array als int's, bei einer map kannst du auch die Namen als String eintragen) und kannst mit <code>geld_ziel = geld_quelle*umrechnung[quelle]/umrechnung[ziel];</code> umrechnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332249</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332249</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 25 Jul 2007 12:16:51 GMT</pubDate></item><item><title><![CDATA[Reply to Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases on Wed, 25 Jul 2007 12:43:00 GMT]]></title><description><![CDATA[<p>Jup, habs mal eben ausprobiert. Geht ganz ohne if bzw. switch/case.</p>
<p>Hier mal mein dolles Programm als Anregung. Man könnte das aber, wie CStoll schon gesagt hat besser mit ner map&lt;std::string, double&gt; machen.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

const long double WAEHRUNG_ZU_US_DOLLAR[] =
    { 1.0L, 1.38218L, 0.008282L, 0.83019L, 2.06210L, 0.03938L };

int main()
{
    std::cout &lt;&lt; &quot;[0] US - Dollar\n&quot;
              &lt;&lt; &quot;[1] Euro\n&quot;
              &lt;&lt; &quot;[2] Japanischer Yen\n&quot;
              &lt;&lt; &quot;[3] Schweizer Franken\n&quot;
              &lt;&lt; &quot;[4] Britische Pfund\n&quot;
              &lt;&lt; &quot;[5] Russicher Rubel\n&quot; &lt;&lt; std::endl;

    std::cout &lt;&lt; &quot;Betrag: &quot;;
    long double betrag = 0.0;
    std::cin &gt;&gt; betrag;

    std::cout &lt;&lt; &quot;Start - Währung: &quot;;
    int startWaehrung;
    std::cin &gt;&gt; startWaehrung;

    std::cout &lt;&lt; &quot;Ziel - Währung: &quot;;
    int zielWaehrung;
    std::cin &gt;&gt; zielWaehrung;

    long double zielBetrag =
        betrag * WAEHRUNG_ZU_US_DOLLAR[startWaehrung] / WAEHRUNG_ZU_US_DOLLAR[zielWaehrung];

    std::cout &lt;&lt; &quot;Ziel - Betrag: &quot; &lt;&lt; zielBetrag &lt;&lt; std::endl;

    return 0;
}
</code></pre>
<p>Gruß<br />
Don06</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332275</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332275</guid><dc:creator><![CDATA[Don06]]></dc:creator><pubDate>Wed, 25 Jul 2007 12:43:00 GMT</pubDate></item><item><title><![CDATA[Reply to Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases on Wed, 08 Jul 2009 11:31:24 GMT]]></title><description><![CDATA[<p>Könnten nicht besser auch enums benutzt werden? Eigentlich das Gebiet der Enums.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1739138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1739138</guid><dc:creator><![CDATA[kurz-und-knapp]]></dc:creator><pubDate>Wed, 08 Jul 2009 11:31:24 GMT</pubDate></item><item><title><![CDATA[Reply to Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases on Wed, 08 Jul 2009 11:35:14 GMT]]></title><description><![CDATA[<p>enum &lt;=&gt; ganzzahltyp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1739139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1739139</guid><dc:creator><![CDATA[enumerat0r]]></dc:creator><pubDate>Wed, 08 Jul 2009 11:35:14 GMT</pubDate></item><item><title><![CDATA[Reply to Währungsumrechner ohne x-viele If&#x27;s&#x2F;Cases on Wed, 08 Jul 2009 12:26:40 GMT]]></title><description><![CDATA[<p>Ich möchte nur darauf hinweisen, das wenn es mehr als nur eine Währungsumrechnung für &quot;Homezwecke&quot; ist, ggf. noch bestimmte Regeln zur Umrechnung beachtet werden müssen (z.B. wurde bei der Euroeinführung für die Umrechnung jeweils 2 Zahlenpaare verwendet - man durfte nicht einfach die Rückrechnung mit dem Kehrwert des ersten machen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1739170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1739170</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Wed, 08 Jul 2009 12:26:40 GMT</pubDate></item></channel></rss>