<?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[Fragen zur Formatierung]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein kleineres Formatierungsproblem. Das Programm macht eigentlich was es sollte. Die Funktionen für die Berechnung der Werte können natürlich auch direkt von der cmath lib genommen werden. Aber ich benötige diese um diese später evt. noch zu erweitern.</p>
<p>Die auszugebene Tabelle sollte untereinander stehen, aber irgendwie funktioniert dies nicht.<br />
Zu einem für die Überschriften und zum anderen werden die Werte nicht auf die Stellen gekürzt.</p>
<p>Hat jemand eine Idee wie ich das besser hinbekommen kann, bzw. zum Laufen bekomme?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cmath&gt;
using namespace std;

double sinus (double x);                   //Funktions Prototype
double cosinus (double x);                 //Funktions Prototype
double hoch (double x);                    //Funktions Prototype
double durchlauf (double x, double y, double z, int a); //Funktions Prototype

int main () {

    int sigziffern;
    double schritte, startwert, endwert;

     cout &lt;&lt; &quot;Bitte Startwert fuer x eingeben: &quot;;
     cin &gt;&gt; startwert;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt; &quot;Bitte Endwert fuer x eingeben: &quot;;
     cin &gt;&gt; endwert;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt; &quot;Bitte Schrittweite fuer x eingeben: &quot;;
     cin &gt;&gt; schritte;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt; &quot;Wieviele signifikante Ziffern sollen angezeigt werden: &quot;;
     cin &gt;&gt; sigziffern;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt;setw(sigziffern) &lt;&lt; &quot;x&quot; &lt;&lt;&quot;| sin(x)&quot; &lt;&lt; setw(sigziffern)
     &lt;&lt; &quot;| cos(x)&quot; &lt;&lt; setw(sigziffern) &lt;&lt; &quot;| x^2&quot; &lt;&lt; setw(sigziffern) &lt;&lt; &quot;\n&quot;;

     durchlauf (startwert, endwert, schritte, sigziffern);

     return 0;

}

double durchlauf (double x, double y, double z, int a) {                        // while Schleife fuer den Durchlauf der einzelnen Felder

       while (x&lt;y || x==y) {
           cout &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific &lt;&lt; setprecision(a) &lt;&lt; x &lt;&lt; &quot;|&quot;
           &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(a) &lt;&lt; sinus(x) &lt;&lt; &quot;|&quot;
           &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(a) &lt;&lt; cosinus(x) &lt;&lt; &quot;|&quot;
           &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(a) &lt;&lt; hoch(x) &lt;&lt; &quot;|&quot;
           &lt;&lt; &quot;\n&quot;;
           x = x+z;
       }      

}

double sinus (double x) {                    //Funktion für Sinus Berechnung
       return sin(x);
       }

double cosinus (double x) {                  //Funktion für Cosinus Berechnung
       return cos(x);
       }

double hoch (double x) {                     //Funktion für Hoch Berechnung
       return x*x;
       }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/317731/fragen-zur-formatierung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Jul 2026 14:21:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317731.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Jun 2013 21:09:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fragen zur Formatierung on Tue, 18 Jun 2013 21:09:52 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein kleineres Formatierungsproblem. Das Programm macht eigentlich was es sollte. Die Funktionen für die Berechnung der Werte können natürlich auch direkt von der cmath lib genommen werden. Aber ich benötige diese um diese später evt. noch zu erweitern.</p>
<p>Die auszugebene Tabelle sollte untereinander stehen, aber irgendwie funktioniert dies nicht.<br />
Zu einem für die Überschriften und zum anderen werden die Werte nicht auf die Stellen gekürzt.</p>
<p>Hat jemand eine Idee wie ich das besser hinbekommen kann, bzw. zum Laufen bekomme?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cmath&gt;
using namespace std;

double sinus (double x);                   //Funktions Prototype
double cosinus (double x);                 //Funktions Prototype
double hoch (double x);                    //Funktions Prototype
double durchlauf (double x, double y, double z, int a); //Funktions Prototype

int main () {

    int sigziffern;
    double schritte, startwert, endwert;

     cout &lt;&lt; &quot;Bitte Startwert fuer x eingeben: &quot;;
     cin &gt;&gt; startwert;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt; &quot;Bitte Endwert fuer x eingeben: &quot;;
     cin &gt;&gt; endwert;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt; &quot;Bitte Schrittweite fuer x eingeben: &quot;;
     cin &gt;&gt; schritte;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt; &quot;Wieviele signifikante Ziffern sollen angezeigt werden: &quot;;
     cin &gt;&gt; sigziffern;
     cout &lt;&lt; &quot;\n\n&quot;;

     cout &lt;&lt;setw(sigziffern) &lt;&lt; &quot;x&quot; &lt;&lt;&quot;| sin(x)&quot; &lt;&lt; setw(sigziffern)
     &lt;&lt; &quot;| cos(x)&quot; &lt;&lt; setw(sigziffern) &lt;&lt; &quot;| x^2&quot; &lt;&lt; setw(sigziffern) &lt;&lt; &quot;\n&quot;;

     durchlauf (startwert, endwert, schritte, sigziffern);

     return 0;

}

double durchlauf (double x, double y, double z, int a) {                        // while Schleife fuer den Durchlauf der einzelnen Felder

       while (x&lt;y || x==y) {
           cout &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific &lt;&lt; setprecision(a) &lt;&lt; x &lt;&lt; &quot;|&quot;
           &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(a) &lt;&lt; sinus(x) &lt;&lt; &quot;|&quot;
           &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(a) &lt;&lt; cosinus(x) &lt;&lt; &quot;|&quot;
           &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(a) &lt;&lt; hoch(x) &lt;&lt; &quot;|&quot;
           &lt;&lt; &quot;\n&quot;;
           x = x+z;
       }      

}

double sinus (double x) {                    //Funktion für Sinus Berechnung
       return sin(x);
       }

double cosinus (double x) {                  //Funktion für Cosinus Berechnung
       return cos(x);
       }

double hoch (double x) {                     //Funktion für Hoch Berechnung
       return x*x;
       }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2332315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2332315</guid><dc:creator><![CDATA[Tyle]]></dc:creator><pubDate>Tue, 18 Jun 2013 21:09:52 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zur Formatierung on Wed, 11 Jun 2014 23:19:58 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2332327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2332327</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 11 Jun 2014 23:19:58 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zur Formatierung on Tue, 18 Jun 2013 21:53:49 GMT]]></title><description><![CDATA[<p>Da wir nicht genau wissen können, wie das scientific-Format aussieht (z.B. Anzahl der Ziffern des Exponenten), fällt mir als Notnagel nur so etwas ein:</p>
<pre><code>unsigned length;
     {
         stringstream s;
         s &lt;&lt; left &lt;&lt; showpos &lt;&lt; scientific  &lt;&lt; setprecision(sigziffern) &lt;&lt; 1.0;
         length = s.str().size();
     }
     // length in setw benutzen
</code></pre>
<p>Oder, da setw nicht gut zum Zentrieren ist und mir das aber besser gefällt, basteln wir uns auch noch etwas dafür:<br />
<a href="http://ideone.com/IvQKXZ" rel="nofollow">http://ideone.com/IvQKXZ</a></p>
<p><em>Eigentlich</em> würde ich aber einfach Tabs nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2332333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2332333</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 18 Jun 2013 21:53:49 GMT</pubDate></item></channel></rss>