<?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[vorzeichen als Pixelmatrix darstellen 1]]></title><description><![CDATA[<p>Das Programm soll eine int-zahl einlesen und die Zahl als Pixelmatrix ausgeben.<br />
Die Ausgabe von positiven Int-werten ist kein Problem,<br />
kommt aber ein Vorzeichen vor der zahl, weiß ich nicht mehr weiter.</p>
<p>die matrix sieht so aus:</p>
<pre><code class="language-cpp">const int zeichen = 12;
const pixel_font_t matrix[zeichen] = {
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', 'X', 'X'},
        {'X', ' ', 'X', ' ', 'X'},
        {'X', ' ', 'X', ' ', 'X'},
        {'X', 'X', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', 'X', ' '},
        {' ', 'X', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {'X', ' ', ' ', ' ', ' '},
        {'X', 'X', 'X', 'X', 'X'}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', 'X', 'X', ' '},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', 'X', ' '},
        {' ', 'X', ' ', 'X', ' '},
        {'X', ' ', ' ', 'X', ' '},
        {'X', 'X', 'X', 'X', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '}
    },
    {
        {'X', 'X', 'X', 'X', 'X'},
        {'X', ' ', ' ', ' ', ' '},
        {'X', ' ', ' ', ' ', ' '},
        {'X', 'X', 'X', 'X', ' '},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'x', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', ' '},
        {'X', ' ', 'X', 'X', ' '},
        {'X', 'X', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {'X', 'X', 'X', 'X', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', 'X', 'X'},
        {' ', 'X', 'X', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {'X', ' ', ' ', ' ', ' '}
    },
    {
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {'X', 'X', 'X', 'X', 'X'},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '}
    }
};
</code></pre>
<pre><code class="language-cpp">int fillPixelLineWithInt(int int_input, pixel_int_line_t char_output)
{
    int int_output, addfield;

    //Ermittelt Anzahl der Stellen der eingegebenen Zahl
    if (int_input &lt; 0)
    {
    //Wenn int_input negativ ist, dann eine Stelle mehr wg. Vorzeichen
        addfield = 2;
    }
    else
    {
        addfield = 1;
    }
    int_output=log10((double)int_input)+ addfield;

    //Füllen des Arrays mit INT-wert
    char chararray[13];
    sprintf( chararray,&quot;%d&quot;, int_input);

    int indexstelle = 0;

    for( int zeile = 0; zeile &lt; 8; zeile = zeile + 1)
    {
        for( int index = indexstelle; index &lt; int_output; index = index + 1)
        {

            for( int spalte = 0; spalte &lt; 5; spalte = spalte + 1)
            {
                char_output[zeile][(spalte +(index * 6))]=matrix[chararray[index]-'0'][zeile][spalte];
            }
        }
    }

    for( int zeile = 0; zeile &lt; 8; zeile = zeile + 1)
        {
            for( int spalte = 0; spalte &lt; (6 * int_output); spalte = spalte + 1)
            {
                printf( &quot;%c&quot;, char_output[zeile][spalte]);
            }
           cout &lt;&lt; &quot;\n&quot;;
        }

    //Rückgabe der Stellen
    return int_output;
}
</code></pre>
<p>Da die Pixelmatrix für '-' in matrix[11] abgelegt ist, wollte ich prüfen ob int_input negativ ist und wenn das der fall ist, sollen die ersten 5 bzw 6 spalten mit der Pixelmatrix für'-' gefüllt werden.<br />
Ich dachte mir das so:</p>
<pre><code class="language-cpp">if (int_input &lt; 0)
	{    
		for( int zeile = 0; zeile &lt; 8; zeile = zeile + 1)
		{
			for( int spalte = 0; spalte &lt; 5; spalte = spalte + 1)
			{
					char_output[zeile][spalte] = matrix[11][zeile][spalte];

			}

		}
		indexstelle = 1;
	}
</code></pre>
<p>Das programm gibt dann aber nichts aus.<br />
Wo liegt der Fehler???????</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/228993/vorzeichen-als-pixelmatrix-darstellen-1</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 05:40:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/228993.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Dec 2008 16:27:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to vorzeichen als Pixelmatrix darstellen 1 on Fri, 05 Dec 2008 17:14:50 GMT]]></title><description><![CDATA[<p>Das Programm soll eine int-zahl einlesen und die Zahl als Pixelmatrix ausgeben.<br />
Die Ausgabe von positiven Int-werten ist kein Problem,<br />
kommt aber ein Vorzeichen vor der zahl, weiß ich nicht mehr weiter.</p>
<p>die matrix sieht so aus:</p>
<pre><code class="language-cpp">const int zeichen = 12;
const pixel_font_t matrix[zeichen] = {
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', 'X', 'X'},
        {'X', ' ', 'X', ' ', 'X'},
        {'X', ' ', 'X', ' ', 'X'},
        {'X', 'X', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', 'X', ' '},
        {' ', 'X', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {'X', ' ', ' ', ' ', ' '},
        {'X', 'X', 'X', 'X', 'X'}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', 'X', 'X', ' '},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', 'X', ' '},
        {' ', 'X', ' ', 'X', ' '},
        {'X', ' ', ' ', 'X', ' '},
        {'X', 'X', 'X', 'X', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '}
    },
    {
        {'X', 'X', 'X', 'X', 'X'},
        {'X', ' ', ' ', ' ', ' '},
        {'X', ' ', ' ', ' ', ' '},
        {'X', 'X', 'X', 'X', ' '},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'x', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', ' '},
        {'X', ' ', 'X', 'X', ' '},
        {'X', 'X', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {'X', 'X', 'X', 'X', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', 'X', 'X', 'X', ' '},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', 'X', 'X'},
        {' ', 'X', 'X', ' ', 'X'},
        {' ', ' ', ' ', ' ', 'X'},
        {'X', ' ', ' ', ' ', 'X'},
        {' ', 'X', 'X', 'X', ' '}
    },
    {
        {' ', ' ', ' ', ' ', 'X'},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', ' ', 'X', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', ' ', 'X', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {' ', 'X', ' ', ' ', ' '},
        {'X', ' ', ' ', ' ', ' '}
    },
    {
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {'X', 'X', 'X', 'X', 'X'},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '},
        {' ', ' ', ' ', ' ', ' '}
    }
};
</code></pre>
<pre><code class="language-cpp">int fillPixelLineWithInt(int int_input, pixel_int_line_t char_output)
{
    int int_output, addfield;

    //Ermittelt Anzahl der Stellen der eingegebenen Zahl
    if (int_input &lt; 0)
    {
    //Wenn int_input negativ ist, dann eine Stelle mehr wg. Vorzeichen
        addfield = 2;
    }
    else
    {
        addfield = 1;
    }
    int_output=log10((double)int_input)+ addfield;

    //Füllen des Arrays mit INT-wert
    char chararray[13];
    sprintf( chararray,&quot;%d&quot;, int_input);

    int indexstelle = 0;

    for( int zeile = 0; zeile &lt; 8; zeile = zeile + 1)
    {
        for( int index = indexstelle; index &lt; int_output; index = index + 1)
        {

            for( int spalte = 0; spalte &lt; 5; spalte = spalte + 1)
            {
                char_output[zeile][(spalte +(index * 6))]=matrix[chararray[index]-'0'][zeile][spalte];
            }
        }
    }

    for( int zeile = 0; zeile &lt; 8; zeile = zeile + 1)
        {
            for( int spalte = 0; spalte &lt; (6 * int_output); spalte = spalte + 1)
            {
                printf( &quot;%c&quot;, char_output[zeile][spalte]);
            }
           cout &lt;&lt; &quot;\n&quot;;
        }

    //Rückgabe der Stellen
    return int_output;
}
</code></pre>
<p>Da die Pixelmatrix für '-' in matrix[11] abgelegt ist, wollte ich prüfen ob int_input negativ ist und wenn das der fall ist, sollen die ersten 5 bzw 6 spalten mit der Pixelmatrix für'-' gefüllt werden.<br />
Ich dachte mir das so:</p>
<pre><code class="language-cpp">if (int_input &lt; 0)
	{    
		for( int zeile = 0; zeile &lt; 8; zeile = zeile + 1)
		{
			for( int spalte = 0; spalte &lt; 5; spalte = spalte + 1)
			{
					char_output[zeile][spalte] = matrix[11][zeile][spalte];

			}

		}
		indexstelle = 1;
	}
</code></pre>
<p>Das programm gibt dann aber nichts aus.<br />
Wo liegt der Fehler???????</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1625887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1625887</guid><dc:creator><![CDATA[hagbard7995]]></dc:creator><pubDate>Fri, 05 Dec 2008 17:14:50 GMT</pubDate></item><item><title><![CDATA[Reply to vorzeichen als Pixelmatrix darstellen 1 on Fri, 05 Dec 2008 16:36:07 GMT]]></title><description><![CDATA[<p>Füg in deinen Post mal C++Code-Tags ein, dann kann man dir helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1625896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1625896</guid><dc:creator><![CDATA[rean]]></dc:creator><pubDate>Fri, 05 Dec 2008 16:36:07 GMT</pubDate></item><item><title><![CDATA[Reply to vorzeichen als Pixelmatrix darstellen 1 on Sat, 06 Dec 2008 14:30:17 GMT]]></title><description><![CDATA[<p>Sorry für Doppelpost aber sonst liest der Threadersteller die Antwort wahrscheinlich nicht.</p>
<p>1.Benutze den Debugger!<br />
Hättest du den benutzt wärst du nach ein paar Sekunden selbst auf den Fehler gestoßen!</p>
<p>2. Gib nächstes mal auch deine typedefs an<br />
Ist in dem Fall zwar nicht so schwierig die zu erraten aber in anderen Fällen könnte ein Fehlverhalten auch an einem falschen typedef liegen.</p>
<p>3. Benutze den Debugger!!</p>
<p>4. Was hast du den in der Schule über Logarithmen gelernt?<br />
Was genau gibt log10(x) zurück:<br />
Mit welcher Zahl du 10 potenzieren musst um x zu erhalten.<br />
Kann 10 hoch irgendeine Zahl jemals negativ werden?</p>
<p><a href="http://www.cplusplus.com/reference/clibrary/cmath/log10.html" rel="nofollow">If the argument is negative, a domain error occurs, setting the global variable errno to the value EDOM.</a></p>
<p>Lösung: <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/abs.html" rel="nofollow">abs</a></p>
<p>5. Benutze den Debugger!!!!</p>
<p>6. Scheinen noch ein paar andere Fehler drin zu sein aber die wirst du ja jetzt selber lösen können weil du den Debugger verwendest!!!!111einseinself</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
<p>hf</p>
<p>rean</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1626176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1626176</guid><dc:creator><![CDATA[rean]]></dc:creator><pubDate>Sat, 06 Dec 2008 14:30:17 GMT</pubDate></item></channel></rss>