<?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[Gleichverteilte Gewichte]]></title><description><![CDATA[<p>Wer kann mir helfen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> Ich habe ein datei cars.txt und eine Matrix data[500][40]und möchte eine Funktion &quot;gleichverteilung&quot; implementieren,so dass ich die Gewichte=&quot;weights&quot; für diese Daten anfangs mit 1.0/anzahl_daten setzen kann.Danke im Voraus für jede Hilfe!<br />
int gleichvert (double* weights,double* daten,int anzahl_daten)<br />
{<br />
//double daten[500][40];<br />
int anzahl_daten=daten.size();<br />
int k;<br />
for(k=0;k&lt;anzahl_daten;k++)<br />
{<br />
weights[k]=1.0/((double) daten);<br />
}</p>
<p>}<br />
int main()<br />
{<br />
ifstream input_file(&quot;cars.txt&quot;);<br />
if(!input_file){<br />
cerr&lt;&lt;&quot;Failed to open statlaba.txt&quot;&lt;&lt;endl;<br />
exit(EXIT_FAILURE);<br />
}<br />
else cout &lt;&lt;&quot;File opened&quot; &lt;&lt;endl;<br />
float data[500][40];<br />
int i,j;<br />
for(i=0;i&lt;500;i++){<br />
for(j=0;j&lt;40;j++){<br />
input_file &gt;&gt; data[i][j];</p>
<p>}}<br />
return 0;<br />
}[cpp]</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161591/gleichverteilte-gewichte</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 22:04:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161591.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Oct 2006 15:13:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Gleichverteilte Gewichte on Sun, 08 Oct 2006 15:13:02 GMT]]></title><description><![CDATA[<p>Wer kann mir helfen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> Ich habe ein datei cars.txt und eine Matrix data[500][40]und möchte eine Funktion &quot;gleichverteilung&quot; implementieren,so dass ich die Gewichte=&quot;weights&quot; für diese Daten anfangs mit 1.0/anzahl_daten setzen kann.Danke im Voraus für jede Hilfe!<br />
int gleichvert (double* weights,double* daten,int anzahl_daten)<br />
{<br />
//double daten[500][40];<br />
int anzahl_daten=daten.size();<br />
int k;<br />
for(k=0;k&lt;anzahl_daten;k++)<br />
{<br />
weights[k]=1.0/((double) daten);<br />
}</p>
<p>}<br />
int main()<br />
{<br />
ifstream input_file(&quot;cars.txt&quot;);<br />
if(!input_file){<br />
cerr&lt;&lt;&quot;Failed to open statlaba.txt&quot;&lt;&lt;endl;<br />
exit(EXIT_FAILURE);<br />
}<br />
else cout &lt;&lt;&quot;File opened&quot; &lt;&lt;endl;<br />
float data[500][40];<br />
int i,j;<br />
for(i=0;i&lt;500;i++){<br />
for(j=0;j&lt;40;j++){<br />
input_file &gt;&gt; data[i][j];</p>
<p>}}<br />
return 0;<br />
}[cpp]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1151474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1151474</guid><dc:creator><![CDATA[whiterose]]></dc:creator><pubDate>Sun, 08 Oct 2006 15:13:02 GMT</pubDate></item><item><title><![CDATA[Reply to Gleichverteilte Gewichte on Sun, 08 Oct 2006 20:59:08 GMT]]></title><description><![CDATA[<p>whiterose schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int gleichvert (double* weights,double* daten,int anzahl_daten)
{
    //double daten[500][40];
    int anzahl_daten=daten.size();
    int k;
    for(k=0; k&lt;anzahl_daten; k++)
    {
        weights[k]=1.0/((double) daten);
    }

}
</code></pre>
</blockquote>
<p>Hier</p>
<pre><code class="language-cpp">int anzahl_daten=daten.size();
</code></pre>
<p>musst Du Dich schon entscheiden, ob Du mit STL-Containern oder C-Arrray arbeiten möchtest.</p>
<p>Und Das hier</p>
<pre><code class="language-cpp">weights[k]=1.0/((double) daten);
</code></pre>
<p>müsste doch</p>
<pre><code class="language-cpp">weights[k]=1.0/((double) anzahl_daten);
</code></pre>
<p>heißen.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1151688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1151688</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 08 Oct 2006 20:59:08 GMT</pubDate></item></channel></rss>