<?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[Komplexe Kodierung]]></title><description><![CDATA[<p>Moin!</p>
<p>Ich habe das oben genannte Programm aus &quot;Algorithmn und Problemlösungen mit C++&quot;<br />
ausgeführt und es kam nicht zu dem aufgeführten Ergebnis.</p>
<pre><code>0 1 1 1
191 -192 11 -12
0 0 1 1
46185 -80102 15 5
-262144 0 0 27973 -16809 -2 13
6222 -16809 -2 13
7973 -1108 2 2
3560 -1908 -16 4
29443 44463 -6 14
-11425 5080 4 -10
-8 -210 5 -6
</code></pre>
<p>wurde zu</p>
<pre><code>nicht kodierbar
nicht kodierbar
...
</code></pre>
<p>Als Ergebnis soll</p>
<pre><code>nicht kodierbar
16, 15
0
nicht kodierbar
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
8, 11, 7, 3
2, 0, 2, 1, 1, 2, 1, 2, 1
15, 3, 8
nicht kodierbar
10, 1, 4, 3
3, 5, 0
</code></pre>
<p>ausgegeben werden.</p>
<p>Hat jemand eine Idee?</p>
<p>Danke</p>
<p>Edit: Aufgrund der Größe des Codes und der Forunrichtlinien habe ich den Code erstmal weggelassen. Sollte Interesse bestehen, kann dieser nachgeliefert werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/325657/komplexe-kodierung</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 13:24:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/325657.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 May 2014 13:42:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 13:44:42 GMT]]></title><description><![CDATA[<p>Moin!</p>
<p>Ich habe das oben genannte Programm aus &quot;Algorithmn und Problemlösungen mit C++&quot;<br />
ausgeführt und es kam nicht zu dem aufgeführten Ergebnis.</p>
<pre><code>0 1 1 1
191 -192 11 -12
0 0 1 1
46185 -80102 15 5
-262144 0 0 27973 -16809 -2 13
6222 -16809 -2 13
7973 -1108 2 2
3560 -1908 -16 4
29443 44463 -6 14
-11425 5080 4 -10
-8 -210 5 -6
</code></pre>
<p>wurde zu</p>
<pre><code>nicht kodierbar
nicht kodierbar
...
</code></pre>
<p>Als Ergebnis soll</p>
<pre><code>nicht kodierbar
16, 15
0
nicht kodierbar
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
8, 11, 7, 3
2, 0, 2, 1, 1, 2, 1, 2, 1
15, 3, 8
nicht kodierbar
10, 1, 4, 3
3, 5, 0
</code></pre>
<p>ausgegeben werden.</p>
<p>Hat jemand eine Idee?</p>
<p>Danke</p>
<p>Edit: Aufgrund der Größe des Codes und der Forunrichtlinien habe ich den Code erstmal weggelassen. Sollte Interesse bestehen, kann dieser nachgeliefert werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2398809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398809</guid><dc:creator><![CDATA[freddy krüger]]></dc:creator><pubDate>Mon, 12 May 2014 13:44:42 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 13:45:32 GMT]]></title><description><![CDATA[<p>Versetz dich mal in unsere Lage: wir wissen weder was &quot;Algorithmen und Problemlösungen mit C++&quot; ist (Website? Buch? Was anderes?) Noch kennen wir die Aufgabe, noch den Code den Du benutzt hast. Wie soll Dir denn da jemand ne hilfreiche Antwort geben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2398812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398812</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Mon, 12 May 2014 13:45:32 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 13:47:36 GMT]]></title><description><![CDATA[<p>Es handelt sich um ein Buch.</p>
<p>Für eineKomplexe Kodierung wird folgender Code benutzt:</p>
<pre><code>#include &lt;cmath&gt;
#include &lt;math.h&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;

const char* const MSG_ERR = &quot;nicht kodierbar&quot;;

using namespace std;

// ------- Deklration der Klasse Complex ----- //

class Complex{

	private:
		long _re, _im;

	public:
		Complex() {};
		Complex(long re, long im): _re(re), _im(im){}
		~Complex() {};
		double getModul() const;
		Complex operator-(Complex&amp;);
		Complex operator-(long);
		Complex operator*(Complex&amp;);
		Complex operator/(Complex&amp;);
		int operator==(long);
		friend istream&amp; operator&gt;&gt;(istream&amp;, Complex&amp;);
};

// ------ Implentierung der Klasse Complex ------ //
inline double Complex::getModul() const{

	double aux = _re*_re + _im*_im;
	return sqrt(aux);

}

inline Complex Complex::operator-(Complex &amp;z) {

	return Complex( _re - z._re, _im - z._im);

}

inline Complex Complex::operator-(long l) {

	return Complex(_re - l, _im);

}

inline Complex Complex::operator* (Complex &amp;z){

	return
		Complex(_re*z._re - _im*z._im, _re*z._im + _im*z._re);

}

inline Complex Complex::operator/(Complex &amp;z) {

	long r = z._re;
	long i = z._im;
	long m2 = r*r + i*i;
	return
		Complex((_re*r + _im*i ) /m2, (_im*r - _re*i) /m2);

}

inline int Complex::operator==(long l) {

	return
		(_re==1 &amp;&amp; _im==0);

}

// -- Imlenmentierung der friend-Methode der Klasse Complex --- //

istream&amp; operator&gt;&gt;( istream &amp;is, Complex &amp;u ) {

	is &gt;&gt; u._re &gt;&gt; u._im;
	return is;

}

// --------- lokale Methode -------------------------------//
inline Complex operator%(Complex &amp;z1, Complex &amp;z2) {

	Complex z;
    Complex a;
    a=(z1/z2);
    a=z2 * a;
	z = z1 - a;
	return z;

}

inline int operator!=(Complex &amp;z, long l) {

	return (!(z == 1));

}

void writeSolution(const vector&lt;int&gt;&amp; v, ofstream &amp;out) {

	vector&lt;int&gt;::const_reverse_iterator itEnd = v.rend();
	vector&lt;int&gt;::const_reverse_iterator it;
	for(it = v.rbegin(); it != (itEnd-1); it++)
		out &lt;&lt; *it &lt;&lt; &quot;,&quot;;
	out &lt;&lt; *it;
	out &lt;&lt; endl;

}

void process(Complex &amp;X, Complex &amp;B, ofstream&amp; out) {

	vector&lt;int&gt;	V;
	Complex ZAux;
	double temp = B.getModul();
	int aMax = (int)temp;
	if(temp - aMax == 0) aMax--;
	if(X==0) {V.push_back(0);}
	short j=0;
	for( ; (j&lt;100) &amp;&amp; (X != 0); j++) {

		bool gefunden = false;
		for(int i=0; i&lt;=aMax; i++) {

			ZAux = X -i;
			if(ZAux % B == 0) {

				V.push_back(i);
				X = ZAux / B;
				gefunden = true;
				break;

			}

		}

		if(!gefunden) {out &lt;&lt; MSG_ERR &lt;&lt; endl; break;}

	}

	if(X==0) {writeSolution(V, out);}
	else if(j==100) {out &lt;&lt; MSG_ERR &lt;&lt; endl;}

}

// ---------- Hauptprogramm ------ //

int main() {

	Complex X ,B;
	ifstream in(&quot;code.in&quot;);
	ofstream out(&quot;code.out&quot;);
	while(in &amp;&amp; !in.eof() &amp;&amp; in &gt;&gt; X &gt;&gt; B) {

		process(X, B, out);

	}

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2398813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398813</guid><dc:creator><![CDATA[freddy krüger]]></dc:creator><pubDate>Mon, 12 May 2014 13:47:36 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 13:52:37 GMT]]></title><description><![CDATA[<p>das buch sollte wohl eher &quot;algorithmen und problemlösungen in c mit klassen&quot; heissen. in zeile 71 dürfte übrigens der / ein fehler sein. du musst mit l vergleichen, nicht mit 1.<br />
edit: in zeile 100 ebenso.</p>
<p>wieso eine kaputte schlechte klasse für komplexe zahlen implementiert wird statt std::complex zu nutzen ist mir schleierhaft.</p>
<p>der autor hat offenbar noch nie etwas von const-correctness gehört.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2398816</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398816</guid><dc:creator><![CDATA[Fytch]]></dc:creator><pubDate>Mon, 12 May 2014 13:52:37 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 13:59:19 GMT]]></title><description><![CDATA[<p>Danke für die Hilfe.</p>
<p>Aber irgendwie habe ich immer noch folgende Ausgabe:</p>
<pre><code>nicht kodierbar
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,15
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
</code></pre>
<p>P.S.: ISBN 978-3-8348-0763-2<br />
vieweg + Teubner von Doina Logofatu</p>
<p>2. Auflage und der Titel ist &quot;... mit C++&quot;</p>
<p>Edit: nach dem Beseitigen des 2. Fehlers folgende Ausgabe:</p>
<pre><code>nicht kodierbar
16,15
0
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
nicht kodierbar
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2398817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398817</guid><dc:creator><![CDATA[freddy krüger]]></dc:creator><pubDate>Mon, 12 May 2014 13:59:19 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 14:11:53 GMT]]></title><description><![CDATA[<p>asfdlol schrieb:</p>
<blockquote>
<p>der autor hat offenbar noch nie etwas von const-correctness gehört.</p>
</blockquote>
<p>Ist anscheinend von 2001 und da wars schon veraltet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2398821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398821</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 12 May 2014 14:11:53 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 14:23:24 GMT]]></title><description><![CDATA[<p>Die 2. Auflage von &quot;Algorithmen und Problemlösungen mit C++&quot; in der 2.Auflage und erweiterten Auflage ist von 2010. (Laut Buchinhalt)</p>
<p>Ich weiß immer noch nicht, wo der Fehler liegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2398822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398822</guid><dc:creator><![CDATA[freddy krüger]]></dc:creator><pubDate>Mon, 12 May 2014 14:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to Komplexe Kodierung on Mon, 12 May 2014 14:31:27 GMT]]></title><description><![CDATA[<p>freddy krüger schrieb:</p>
<blockquote>
<p>Ich weiß immer noch nicht, wo der Fehler liegt.</p>
</blockquote>
<p>Du weißt ja, was der Algorithmus tun soll. Benutze einen Debugger!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2398826</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2398826</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 12 May 2014 14:31:27 GMT</pubDate></item></channel></rss>