<?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[Formatierung!!!]]></title><description><![CDATA[<p>Hi und zwar habe ich &quot;immer&quot; das Problem, dass ich die Formatierung nicht richtig hinbekomme. Das heißt komma unter Komma.</p>
<p>Ich weiß das ich ein Header namens iomanip benötige und setprecision(x) und<br />
setiosflags(ios::fixed) bzw. zum Ausgeben des Wertes in der Variable setw(x);</p>
<p>Nun mein Code:</p>
<pre><code>#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;conioex.h&gt;
#include &lt;string&gt;
#include &lt;time.h&gt;
#include &lt;windows.h&gt;
#include &lt;iomanip&gt;

using namespace std;

struct temp
{
       string name;
       int alter;
       float gehalt;
};

temp feld[3];
int auswahl;

void name();
void alter();
void gehalt();

int main(int argc, char *argv[])
{

    do
    {

    setprecision(2);
    setiosflags(ios::fixed);         

    system(&quot;cls&quot;);         

    cout &lt;&lt; &quot;\t\t\t\t&quot;;
    cout &lt;&lt; &quot;Menue&quot;;

    cout &lt;&lt; &quot;\n\n\n\n\n&quot;;

    cout &lt;&lt; &quot;\n\t\t Nach Name                    &lt;1&gt;&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Nach Alter                   &lt;2&gt;&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Nach Gehalt                  &lt;3&gt;&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Ende                         &lt;0&gt;&quot;;

    cout &lt;&lt; &quot;\n\n\n&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Eingabe: &quot;;
    cin &gt;&gt; auswahl;

    switch(auswahl)
    {
                   case 1: {
                            name();
                            break;
                            } 

                   case 2: {
                            alter();
                            break;
                            }       

                   case 3: {
                            gehalt();
                            break;
                            }            
   };

   }
   while(auswahl!=0); 

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
//////////////////////////////////Name/////////////////////////////////////////////////////////
void name()
{

  system(&quot;cls&quot;);

              for(int x=0; x&lt;3; x++)
              {
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Name: &quot;;
                   cin &gt;&gt; feld[x].name;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Alter: &quot;;
                   cin &gt;&gt; feld[x].alter;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Gehalt: &quot;;
                   cin &gt;&gt; feld[x].gehalt;
                   cout &lt;&lt; &quot;\n\n\n&quot;;
              }

  for(int y=0; y&lt;3; y++)
  {
        for(int j=0; j&lt;(3-1); j++)
        {
                if(feld[j].name &gt; feld[j+1].name)
                {
                                ////////Name////////////////////
                                string temp_name = feld[j].name;
                                feld[j].name = feld[j+1].name;
                                feld[j+1].name = temp_name ;
                                /////////Alter/////////////////
                                int temp_alter = feld[j].alter;
                                feld[j].alter = feld[j+1].alter;
                                feld[j+1].alter = temp_alter ;
                                /////////Gehalt/////////////////
                                float temp_gehalt = feld[j].gehalt;
                                feld[j].gehalt = feld[j+1].gehalt;
                                feld[j+1].gehalt = temp_gehalt ;
                }
        }

  }

  system(&quot;cls&quot;);

  gotoxy(35,2);
  cout &lt;&lt; &quot;Ausgabe&quot;; 

  gotoxy(9,10);
  cout &lt;&lt; &quot;Name&quot;;
   gotoxy(32,10);
  cout &lt;&lt; &quot;Alter&quot;;
   gotoxy(55,10);
  cout &lt;&lt; &quot;Gehalt&quot;;

  for(int x=0; x&lt;3; x++)
  {
  cout &lt;&lt; &quot;\n\n&quot;;        
  setprecision(2);
  setiosflags(ios::fixed);       
  cout &lt;&lt; setw(12) &lt;&lt; feld[x].name &lt;&lt; setw(24) &lt;&lt; feld[x].alter &lt;&lt; setw(25) &lt;&lt; feld[x].gehalt;
  } 

  Sleep(9000);

}

//////////////////////////////////Alter/////////////////////////////////////////////////////////
void alter()
{
 system(&quot;cls&quot;);

              for(int x=0; x&lt;3; x++)
              {
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Name: &quot;;
                   cin &gt;&gt; feld[x].name;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Alter: &quot;;
                   cin &gt;&gt; feld[x].alter;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Gehalt: &quot;;
                   cin &gt;&gt; feld[x].gehalt;
                   cout &lt;&lt; &quot;\n\n\n&quot;;
              }

  for(int y=0; y&lt;3; y++)
  {
        for(int j=0; j&lt;(3-1); j++)
        {
                if(feld[j].alter &gt; feld[j+1].alter)
                {
                                ////////Name////////////////////
                                string temp_name = feld[j].name;
                                feld[j].name = feld[j+1].name;
                                feld[j+1].name = temp_name ;
                                /////////Alter/////////////////
                                int temp_alter = feld[j].alter;
                                feld[j].alter = feld[j+1].alter;
                                feld[j+1].alter = temp_alter ;
                                /////////Gehalt/////////////////
                                float temp_gehalt = feld[j].gehalt;
                                feld[j].gehalt = feld[j+1].gehalt;
                                feld[j+1].gehalt = temp_gehalt ;
                }
        }

  }

  system(&quot;cls&quot;);

  gotoxy(35,2);
  cout &lt;&lt; &quot;Ausgabe&quot;; 

  gotoxy(9,10);
  cout &lt;&lt; &quot;Alter&quot;;
   gotoxy(33,10);
  cout &lt;&lt; &quot;Name&quot;;
   gotoxy(55,10);
  cout &lt;&lt; &quot;Gehalt&quot;;

  for(int x=0; x&lt;3; x++)
  {
  cout &lt;&lt; &quot;\n\n&quot;;        
  setprecision(2);
  setiosflags(ios::fixed);            
  cout &lt;&lt; setw(12)&lt;&lt; feld[x].alter &lt;&lt; setw(24) &lt;&lt; feld[x].name &lt;&lt; setw(25) &lt;&lt; feld[x].gehalt;

  } 

  Sleep(9000);
}

//////////////////////////////////Gehalt/////////////////////////////////////////////////////////
void gehalt()
{
 system(&quot;cls&quot;);

              for(int x=0; x&lt;3; x++)
              {
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Name: &quot;;
                   cin &gt;&gt; feld[x].name;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Alter: &quot;;
                   cin &gt;&gt; feld[x].alter;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Gehalt: &quot;;
                   cin &gt;&gt; feld[x].gehalt;
                   cout &lt;&lt; &quot;\n\n\n&quot;;
              }

  for(int y=0; y&lt;3; y++)
  {
        for(int j=0; j&lt;(3-1); j++)
        {
                if(feld[j].gehalt &lt; feld[j+1].gehalt)
                {
                                ////////Name////////////////////
                                string temp_name = feld[j].name;
                                feld[j].name = feld[j+1].name;
                                feld[j+1].name = temp_name ;
                                /////////Alter/////////////////
                                int temp_alter = feld[j].alter;
                                feld[j].alter = feld[j+1].alter;
                                feld[j+1].alter = temp_alter ;
                                /////////Gehalt/////////////////
                                float temp_gehalt = feld[j].gehalt;
                                feld[j].gehalt = feld[j+1].gehalt;
                                feld[j+1].gehalt = temp_gehalt ;
                }
        }

  }

  system(&quot;cls&quot;);

  gotoxy(35,2);
  cout &lt;&lt; &quot;Ausgabe&quot;; 

  gotoxy(9,10);
  cout &lt;&lt; &quot;Gehalt&quot;;
   gotoxy(33,10);
  cout &lt;&lt; &quot;Name&quot;;
   gotoxy(55,10);
  cout &lt;&lt; &quot;Alter&quot;;

  for(int x=0; x&lt;3; x++)
  {
  cout &lt;&lt; &quot;\n\n&quot;;        
  setprecision(2);
  setiosflags(ios::fixed);            
  cout &lt;&lt; setw(12) &lt;&lt; feld[x].gehalt &lt;&lt; setw(24) &lt;&lt; feld[x].name &lt;&lt; setw(25) &lt;&lt; feld[x].alter;
  } 

  Sleep(9000);
}
</code></pre>
<p>Ich hoffe ihr könnt mir weiterhelfen!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/175639/formatierung</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 06:05:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/175639.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Mar 2007 18:45:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Formatierung!!! on Mon, 12 Mar 2007 18:45:13 GMT]]></title><description><![CDATA[<p>Hi und zwar habe ich &quot;immer&quot; das Problem, dass ich die Formatierung nicht richtig hinbekomme. Das heißt komma unter Komma.</p>
<p>Ich weiß das ich ein Header namens iomanip benötige und setprecision(x) und<br />
setiosflags(ios::fixed) bzw. zum Ausgeben des Wertes in der Variable setw(x);</p>
<p>Nun mein Code:</p>
<pre><code>#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;conioex.h&gt;
#include &lt;string&gt;
#include &lt;time.h&gt;
#include &lt;windows.h&gt;
#include &lt;iomanip&gt;

using namespace std;

struct temp
{
       string name;
       int alter;
       float gehalt;
};

temp feld[3];
int auswahl;

void name();
void alter();
void gehalt();

int main(int argc, char *argv[])
{

    do
    {

    setprecision(2);
    setiosflags(ios::fixed);         

    system(&quot;cls&quot;);         

    cout &lt;&lt; &quot;\t\t\t\t&quot;;
    cout &lt;&lt; &quot;Menue&quot;;

    cout &lt;&lt; &quot;\n\n\n\n\n&quot;;

    cout &lt;&lt; &quot;\n\t\t Nach Name                    &lt;1&gt;&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Nach Alter                   &lt;2&gt;&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Nach Gehalt                  &lt;3&gt;&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Ende                         &lt;0&gt;&quot;;

    cout &lt;&lt; &quot;\n\n\n&quot;;
    cout &lt;&lt; &quot;\n\n\t\t Eingabe: &quot;;
    cin &gt;&gt; auswahl;

    switch(auswahl)
    {
                   case 1: {
                            name();
                            break;
                            } 

                   case 2: {
                            alter();
                            break;
                            }       

                   case 3: {
                            gehalt();
                            break;
                            }            
   };

   }
   while(auswahl!=0); 

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
//////////////////////////////////Name/////////////////////////////////////////////////////////
void name()
{

  system(&quot;cls&quot;);

              for(int x=0; x&lt;3; x++)
              {
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Name: &quot;;
                   cin &gt;&gt; feld[x].name;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Alter: &quot;;
                   cin &gt;&gt; feld[x].alter;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Gehalt: &quot;;
                   cin &gt;&gt; feld[x].gehalt;
                   cout &lt;&lt; &quot;\n\n\n&quot;;
              }

  for(int y=0; y&lt;3; y++)
  {
        for(int j=0; j&lt;(3-1); j++)
        {
                if(feld[j].name &gt; feld[j+1].name)
                {
                                ////////Name////////////////////
                                string temp_name = feld[j].name;
                                feld[j].name = feld[j+1].name;
                                feld[j+1].name = temp_name ;
                                /////////Alter/////////////////
                                int temp_alter = feld[j].alter;
                                feld[j].alter = feld[j+1].alter;
                                feld[j+1].alter = temp_alter ;
                                /////////Gehalt/////////////////
                                float temp_gehalt = feld[j].gehalt;
                                feld[j].gehalt = feld[j+1].gehalt;
                                feld[j+1].gehalt = temp_gehalt ;
                }
        }

  }

  system(&quot;cls&quot;);

  gotoxy(35,2);
  cout &lt;&lt; &quot;Ausgabe&quot;; 

  gotoxy(9,10);
  cout &lt;&lt; &quot;Name&quot;;
   gotoxy(32,10);
  cout &lt;&lt; &quot;Alter&quot;;
   gotoxy(55,10);
  cout &lt;&lt; &quot;Gehalt&quot;;

  for(int x=0; x&lt;3; x++)
  {
  cout &lt;&lt; &quot;\n\n&quot;;        
  setprecision(2);
  setiosflags(ios::fixed);       
  cout &lt;&lt; setw(12) &lt;&lt; feld[x].name &lt;&lt; setw(24) &lt;&lt; feld[x].alter &lt;&lt; setw(25) &lt;&lt; feld[x].gehalt;
  } 

  Sleep(9000);

}

//////////////////////////////////Alter/////////////////////////////////////////////////////////
void alter()
{
 system(&quot;cls&quot;);

              for(int x=0; x&lt;3; x++)
              {
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Name: &quot;;
                   cin &gt;&gt; feld[x].name;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Alter: &quot;;
                   cin &gt;&gt; feld[x].alter;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Gehalt: &quot;;
                   cin &gt;&gt; feld[x].gehalt;
                   cout &lt;&lt; &quot;\n\n\n&quot;;
              }

  for(int y=0; y&lt;3; y++)
  {
        for(int j=0; j&lt;(3-1); j++)
        {
                if(feld[j].alter &gt; feld[j+1].alter)
                {
                                ////////Name////////////////////
                                string temp_name = feld[j].name;
                                feld[j].name = feld[j+1].name;
                                feld[j+1].name = temp_name ;
                                /////////Alter/////////////////
                                int temp_alter = feld[j].alter;
                                feld[j].alter = feld[j+1].alter;
                                feld[j+1].alter = temp_alter ;
                                /////////Gehalt/////////////////
                                float temp_gehalt = feld[j].gehalt;
                                feld[j].gehalt = feld[j+1].gehalt;
                                feld[j+1].gehalt = temp_gehalt ;
                }
        }

  }

  system(&quot;cls&quot;);

  gotoxy(35,2);
  cout &lt;&lt; &quot;Ausgabe&quot;; 

  gotoxy(9,10);
  cout &lt;&lt; &quot;Alter&quot;;
   gotoxy(33,10);
  cout &lt;&lt; &quot;Name&quot;;
   gotoxy(55,10);
  cout &lt;&lt; &quot;Gehalt&quot;;

  for(int x=0; x&lt;3; x++)
  {
  cout &lt;&lt; &quot;\n\n&quot;;        
  setprecision(2);
  setiosflags(ios::fixed);            
  cout &lt;&lt; setw(12)&lt;&lt; feld[x].alter &lt;&lt; setw(24) &lt;&lt; feld[x].name &lt;&lt; setw(25) &lt;&lt; feld[x].gehalt;

  } 

  Sleep(9000);
}

//////////////////////////////////Gehalt/////////////////////////////////////////////////////////
void gehalt()
{
 system(&quot;cls&quot;);

              for(int x=0; x&lt;3; x++)
              {
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Name: &quot;;
                   cin &gt;&gt; feld[x].name;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Alter: &quot;;
                   cin &gt;&gt; feld[x].alter;
                   cout &lt;&lt; x+1 &lt;&lt; &quot; Gehalt: &quot;;
                   cin &gt;&gt; feld[x].gehalt;
                   cout &lt;&lt; &quot;\n\n\n&quot;;
              }

  for(int y=0; y&lt;3; y++)
  {
        for(int j=0; j&lt;(3-1); j++)
        {
                if(feld[j].gehalt &lt; feld[j+1].gehalt)
                {
                                ////////Name////////////////////
                                string temp_name = feld[j].name;
                                feld[j].name = feld[j+1].name;
                                feld[j+1].name = temp_name ;
                                /////////Alter/////////////////
                                int temp_alter = feld[j].alter;
                                feld[j].alter = feld[j+1].alter;
                                feld[j+1].alter = temp_alter ;
                                /////////Gehalt/////////////////
                                float temp_gehalt = feld[j].gehalt;
                                feld[j].gehalt = feld[j+1].gehalt;
                                feld[j+1].gehalt = temp_gehalt ;
                }
        }

  }

  system(&quot;cls&quot;);

  gotoxy(35,2);
  cout &lt;&lt; &quot;Ausgabe&quot;; 

  gotoxy(9,10);
  cout &lt;&lt; &quot;Gehalt&quot;;
   gotoxy(33,10);
  cout &lt;&lt; &quot;Name&quot;;
   gotoxy(55,10);
  cout &lt;&lt; &quot;Alter&quot;;

  for(int x=0; x&lt;3; x++)
  {
  cout &lt;&lt; &quot;\n\n&quot;;        
  setprecision(2);
  setiosflags(ios::fixed);            
  cout &lt;&lt; setw(12) &lt;&lt; feld[x].gehalt &lt;&lt; setw(24) &lt;&lt; feld[x].name &lt;&lt; setw(25) &lt;&lt; feld[x].alter;
  } 

  Sleep(9000);
}
</code></pre>
<p>Ich hoffe ihr könnt mir weiterhelfen!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1244243</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1244243</guid><dc:creator><![CDATA[Svolf]]></dc:creator><pubDate>Mon, 12 Mar 2007 18:45:13 GMT</pubDate></item><item><title><![CDATA[Reply to Formatierung!!! on Mon, 12 Mar 2007 19:49:58 GMT]]></title><description><![CDATA[<p>Wenn du deinen Post ins richtige Format bringst hilft dir vielleicht auch jemand...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1244279</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1244279</guid><dc:creator><![CDATA[finix]]></dc:creator><pubDate>Mon, 12 Mar 2007 19:49:58 GMT</pubDate></item><item><title><![CDATA[Reply to Formatierung!!! on Tue, 13 Mar 2007 09:39:07 GMT]]></title><description><![CDATA[<p>Du mußt &quot;setprecision(2);&quot; und &quot;setiosflags(ios::fixed);&quot; direkt vor der Ausgabe der Floatzahlen schreiben (und natürlich in den Stream &quot;cout&quot;), also</p>
<pre><code class="language-cpp">cout &lt;&lt; setw(12) &lt;&lt; feld[x].name &lt;&lt; setw(24) &lt;&lt; feld[x].alter;
cout &lt;&lt; setw(25) &lt;&lt; setprecision(2) &lt;&lt; setiosflags(ios::fixed) &lt;&lt; feld[x].gehalt;
</code></pre>
<p>P.S. Das Sortieren solltest du als eigene Funktion implementieren (du kannst z.B. std::sort dafür aufrufen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1244547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1244547</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Tue, 13 Mar 2007 09:39:07 GMT</pubDate></item></channel></rss>