<?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[Problem bei Ausgabe rechtsformatiert... PLEASE HELP]]></title><description><![CDATA[<p>n abend....</p>
<p>und zwar hab ich folgendes problem. ich poste erstmal die ausgabe die eigentlich ercheinen soll, um mir ein paar worte zu sparen:</p>
<pre><code class="language-cpp">ZEIT      DEC      HEX                GRAFIK

          6.00 Uhr      +5         5                   |*****
         12.00 Uhr      -1  ffffffff                  *|
         18.00 Uhr      +6         6                   |******
         24.00 Uhr      -7  fffffff9            *******|
</code></pre>
<p>so in etwa sollte es aussehen. also mein problem liegt nu bei der grafik. es sollen halt sterne nach links ausgegeben werden, je nachdem wieviel grad minus sind. allerdings haut ds mit meinen formatierungen nicht hin.<br />
wäre cool. wenn mir jemand helfen könnte. ich glaub, all zu schwer ist es nicht. nur irgendwie komm ich nicht drauf.</p>
<p>mein quelltext:</p>
<pre><code class="language-cpp">//temp1.cpp (by) Matthias Walter

#include&lt;iostream.h&gt;
#include&lt;iomanip.h&gt;
#include&lt;windows.h&gt;

void main()
{
	int temp[4], zeit=6, tmp=0;
	const long showpos = 0x400L;

	for(int i=0; i&lt;4; i++)
	{
		do
		{
			cout&lt;&lt;endl;
			cout&lt;&lt;&quot; &quot;&lt;&lt;&quot;Temperatur &quot;&lt;&lt;zeit&lt;&lt;&quot;.00 Uhr: &quot;;
			cin &gt;&gt;temp[i];
			system(&quot;cls&quot;);
			zeit+=6;
			if(temp[i]&lt;-20||temp[i]&gt;20)
			{
				zeit-=6;
			}
		}while(temp[i]&lt;-20||temp[i]&gt;20);
	}
	zeit=6;
	cout&lt;&lt;endl;
	cout&lt;&lt;&quot; &quot;&lt;&lt;setw(12)&lt;&lt;&quot;ZEIT&quot;&lt;&lt;setw(18)&lt;&lt;&quot;DEC      HEX&quot;&lt;&lt;setw(22)&lt;&lt;&quot;GRAFIK&quot;&lt;&lt;endl&lt;&lt;endl;
	for(i=0; i&lt;4;i++)
	{
		cout&lt;&lt;&quot; &quot;&lt;&lt;setw(5)&lt;&lt;resetiosflags(showpos)&lt;&lt;dec&lt;&lt;zeit&lt;&lt;&quot;.00 Uhr&quot;&lt;&lt;setw(8)
			&lt;&lt;setiosflags(showpos)&lt;&lt;temp[i]&lt;&lt;&quot;  &quot;&lt;&lt;setw(8)&lt;&lt;hex&lt;&lt;temp[i];

		if(temp[i]&gt;0)
		{
			cout&lt;&lt;setw(20)&lt;&lt;char(179);
			for(int x=0; x&lt;temp[i]; x++)
			{
				cout&lt;&lt;&quot;*&quot;;
			}
		}
		if(temp[i]&lt;0)
		{
			tmp=temp[i]*(-1);
			for(int x=0; x&lt;tmp; x++)
			{
				cout&lt;&lt;&quot;*&quot;;
			}
			cout&lt;&lt;char(179);
		}
		cout&lt;&lt;endl;

		zeit+=6;
	}
	cout&lt;&lt;endl&lt;&lt;endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/159768/problem-bei-ausgabe-rechtsformatiert-please-help</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 20:25:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159768.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Sep 2006 17:33:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem bei Ausgabe rechtsformatiert... PLEASE HELP on Mon, 18 Sep 2006 17:34:05 GMT]]></title><description><![CDATA[<p>n abend....</p>
<p>und zwar hab ich folgendes problem. ich poste erstmal die ausgabe die eigentlich ercheinen soll, um mir ein paar worte zu sparen:</p>
<pre><code class="language-cpp">ZEIT      DEC      HEX                GRAFIK

          6.00 Uhr      +5         5                   |*****
         12.00 Uhr      -1  ffffffff                  *|
         18.00 Uhr      +6         6                   |******
         24.00 Uhr      -7  fffffff9            *******|
</code></pre>
<p>so in etwa sollte es aussehen. also mein problem liegt nu bei der grafik. es sollen halt sterne nach links ausgegeben werden, je nachdem wieviel grad minus sind. allerdings haut ds mit meinen formatierungen nicht hin.<br />
wäre cool. wenn mir jemand helfen könnte. ich glaub, all zu schwer ist es nicht. nur irgendwie komm ich nicht drauf.</p>
<p>mein quelltext:</p>
<pre><code class="language-cpp">//temp1.cpp (by) Matthias Walter

#include&lt;iostream.h&gt;
#include&lt;iomanip.h&gt;
#include&lt;windows.h&gt;

void main()
{
	int temp[4], zeit=6, tmp=0;
	const long showpos = 0x400L;

	for(int i=0; i&lt;4; i++)
	{
		do
		{
			cout&lt;&lt;endl;
			cout&lt;&lt;&quot; &quot;&lt;&lt;&quot;Temperatur &quot;&lt;&lt;zeit&lt;&lt;&quot;.00 Uhr: &quot;;
			cin &gt;&gt;temp[i];
			system(&quot;cls&quot;);
			zeit+=6;
			if(temp[i]&lt;-20||temp[i]&gt;20)
			{
				zeit-=6;
			}
		}while(temp[i]&lt;-20||temp[i]&gt;20);
	}
	zeit=6;
	cout&lt;&lt;endl;
	cout&lt;&lt;&quot; &quot;&lt;&lt;setw(12)&lt;&lt;&quot;ZEIT&quot;&lt;&lt;setw(18)&lt;&lt;&quot;DEC      HEX&quot;&lt;&lt;setw(22)&lt;&lt;&quot;GRAFIK&quot;&lt;&lt;endl&lt;&lt;endl;
	for(i=0; i&lt;4;i++)
	{
		cout&lt;&lt;&quot; &quot;&lt;&lt;setw(5)&lt;&lt;resetiosflags(showpos)&lt;&lt;dec&lt;&lt;zeit&lt;&lt;&quot;.00 Uhr&quot;&lt;&lt;setw(8)
			&lt;&lt;setiosflags(showpos)&lt;&lt;temp[i]&lt;&lt;&quot;  &quot;&lt;&lt;setw(8)&lt;&lt;hex&lt;&lt;temp[i];

		if(temp[i]&gt;0)
		{
			cout&lt;&lt;setw(20)&lt;&lt;char(179);
			for(int x=0; x&lt;temp[i]; x++)
			{
				cout&lt;&lt;&quot;*&quot;;
			}
		}
		if(temp[i]&lt;0)
		{
			tmp=temp[i]*(-1);
			for(int x=0; x&lt;tmp; x++)
			{
				cout&lt;&lt;&quot;*&quot;;
			}
			cout&lt;&lt;char(179);
		}
		cout&lt;&lt;endl;

		zeit+=6;
	}
	cout&lt;&lt;endl&lt;&lt;endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1139861</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1139861</guid><dc:creator><![CDATA[MW_ICEMAN]]></dc:creator><pubDate>Mon, 18 Sep 2006 17:34:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Ausgabe rechtsformatiert... PLEASE HELP on Mon, 18 Sep 2006 20:12:14 GMT]]></title><description><![CDATA[<p>anbei die korrigierte Stelle, die die Temperatur-Graphik ausgibt:</p>
<pre><code class="language-cpp">if( temp[i]&gt;=0 ) // bei temp[i] == 0 wird nur '|' ausgegeben
        {
            cout &lt;&lt; setw(20) &lt;&lt; char(179);
            for( int x=0; x&lt;temp[i]; x++ )
            {
                cout&lt;&lt;&quot;*&quot;;
            }
        }
        if( temp[i]&lt;0 )
        {
            cout &lt;&lt; setw(20 + temp[i]);
            for( int x=temp[i]; x&lt;0; ++x )
            {
                cout&lt;&lt;&quot;*&quot;;
            }
            cout&lt;&lt;char(179);
        }
</code></pre>
<p>zu empfehlen wäre eine eigene kleine Klasse - hier 'TempBar', die diese Ausgabe übernimmt. Etwa so</p>
<pre><code class="language-cpp">class TempBar
{
public:
    TempBar( int mini, int maxi ) : m_mini( mini ), m_maxi( maxi ), m_temp(0) {}
    TempBar&amp; operator()( int temp )
    {
        m_temp = temp;
        return *this;
    }
    friend std::ostream&amp; operator&lt;&lt;( std::ostream&amp; out, const TempBar&amp; bar )
    {
        out &lt;&lt; std::setw( 2 - bar.m_mini + (bar.m_temp &gt; 0? 0 : bar.m_temp) );
        for( int i = bar.m_temp; i &lt; 0; ++i ) out &lt;&lt; '*';
        out &lt;&lt; '|';
        for( int i = 0; i &lt; bar.m_temp; ++i ) out &lt;&lt; '*';
        return out &lt;&lt; std::setw( 1 + bar.m_maxi - (bar.m_temp &gt; 0? bar.m_temp: 0 ) ) &lt;&lt; ' ';
    }
private:
    int m_mini, m_maxi;
    int m_temp;
};
</code></pre>
<p>.. und der Aufruf vereinfacht sich dann zu</p>
<pre><code class="language-cpp">for( int i=0; i&lt;4; ++i)
    {
        TempBar tb( -20, 20 ); // Temperaturbereich vorgeben
        cout&lt;&lt;&quot; &quot;&lt;&lt;setw(5)&lt;&lt;resetiosflags(showpos)&lt;&lt;dec&lt;&lt;zeit&lt;&lt;&quot;.00 Uhr&quot;&lt;&lt;setw(8)
            &lt;&lt;setiosflags(showpos)&lt;&lt;temp[i]&lt;&lt;&quot;  &quot;&lt;&lt;setw(8)&lt;&lt;hex&lt;&lt;temp[i] &lt;&lt; tb( temp[i] ) &lt;&lt;endl;;

        zeit+=6;
    }
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140012</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Mon, 18 Sep 2006 20:12:14 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Ausgabe rechtsformatiert... PLEASE HELP on Tue, 19 Sep 2006 06:33:28 GMT]]></title><description><![CDATA[<p>jup... danke! funktioniert einwandfrei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140098</guid><dc:creator><![CDATA[MW_ICEMAN]]></dc:creator><pubDate>Tue, 19 Sep 2006 06:33:28 GMT</pubDate></item></channel></rss>