<?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[Maximum eines Arrays bestimmen]]></title><description><![CDATA[<p>Guten Abend zusammen,</p>
<p>ich bereite mich gerade auf eine C++ Klausur vor, und hänge hier gerade an einer wie ich eigentlich dachte einfachen Übungsaufgabe. Die Aufgabe ist das Maximum eines zweidimensionalen Arrays mit Hilfe einer Funktion zu bestimmen. Ich steh aber glaube ich im Moment total auf dem Schlauch.<br />
Als Fehlermeldung gibt mir mein Compiler folgendes aus:</p>
<blockquote>
<p>cannot convert `double' to `double (<em>)[7]' for argument `1' to `double maximum(double (</em>)[7])'</p>
</blockquote>
<p>Der Quellcode sieht wie folgt aus:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;

using namespace std;

double maximum(double matrix[5][7])
{
       double max=matrix[0][0];
       int i,j;
       for(i=0;i&lt;=4;i++)
       {
           for(j=0;j&lt;=6;j++)
           {
               if (max&lt;matrix[i][j])
               {
                   max=matrix[i][j];
               }
           }
       }
       return (max);
}

int main()
{  
    double matrix[5][7]={0},maximal;
    maximal=maximum(matrix[5][7]);
    cout&lt;&lt;maximal;
    cin.get();
}
</code></pre>
<p>Also so wie ich die Fehlermeldung verstehe hat er beim konvertieren Probleme, da ja &quot;maximal&quot; double ist und &quot;matrix&quot; ein array. Aber ich bekomme doch ein double, nämlich &quot;max&quot; von der Funktion zurück, oder? Wo liegt denn hier der Denkfehler???</p>
<p>Vielen Dank für eure Hilfe, ich wage mich mal an die nächste Aufgabe und hoffe auf mehr Erfolg <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/170603/maximum-eines-arrays-bestimmen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 03:33:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/170603.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Jan 2007 19:34:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Maximum eines Arrays bestimmen on Wed, 17 Jan 2007 19:34:34 GMT]]></title><description><![CDATA[<p>Guten Abend zusammen,</p>
<p>ich bereite mich gerade auf eine C++ Klausur vor, und hänge hier gerade an einer wie ich eigentlich dachte einfachen Übungsaufgabe. Die Aufgabe ist das Maximum eines zweidimensionalen Arrays mit Hilfe einer Funktion zu bestimmen. Ich steh aber glaube ich im Moment total auf dem Schlauch.<br />
Als Fehlermeldung gibt mir mein Compiler folgendes aus:</p>
<blockquote>
<p>cannot convert `double' to `double (<em>)[7]' for argument `1' to `double maximum(double (</em>)[7])'</p>
</blockquote>
<p>Der Quellcode sieht wie folgt aus:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;

using namespace std;

double maximum(double matrix[5][7])
{
       double max=matrix[0][0];
       int i,j;
       for(i=0;i&lt;=4;i++)
       {
           for(j=0;j&lt;=6;j++)
           {
               if (max&lt;matrix[i][j])
               {
                   max=matrix[i][j];
               }
           }
       }
       return (max);
}

int main()
{  
    double matrix[5][7]={0},maximal;
    maximal=maximum(matrix[5][7]);
    cout&lt;&lt;maximal;
    cin.get();
}
</code></pre>
<p>Also so wie ich die Fehlermeldung verstehe hat er beim konvertieren Probleme, da ja &quot;maximal&quot; double ist und &quot;matrix&quot; ein array. Aber ich bekomme doch ein double, nämlich &quot;max&quot; von der Funktion zurück, oder? Wo liegt denn hier der Denkfehler???</p>
<p>Vielen Dank für eure Hilfe, ich wage mich mal an die nächste Aufgabe und hoffe auf mehr Erfolg <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211600</guid><dc:creator><![CDATA[hogepoge]]></dc:creator><pubDate>Wed, 17 Jan 2007 19:34:34 GMT</pubDate></item><item><title><![CDATA[Reply to Maximum eines Arrays bestimmen on Wed, 17 Jan 2007 20:02:05 GMT]]></title><description><![CDATA[<p>matrix[5][7] ist aber kein Array, sondern ein double.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211611</guid><dc:creator><![CDATA[Entenwickler]]></dc:creator><pubDate>Wed, 17 Jan 2007 20:02:05 GMT</pubDate></item><item><title><![CDATA[Reply to Maximum eines Arrays bestimmen on Wed, 17 Jan 2007 20:08:12 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int main()
{  
    double matrix[5][7]={0},maximal;
    maximal=maximum(matrix); // Da isser
    cout&lt;&lt;maximal;
    cin.get();
}
</code></pre>
<p>Wenn die Funktion double[5][7] erwartet, dann bekommt sie das auch. matrix[5][7] ist nicht das Array sondern ein (ungültiger!!!) Indexzugriff, liefert also den Typ double zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211614</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Wed, 17 Jan 2007 20:08:12 GMT</pubDate></item><item><title><![CDATA[Reply to Maximum eines Arrays bestimmen on Wed, 17 Jan 2007 20:10:07 GMT]]></title><description><![CDATA[<p>Oh man... Wie doof kann man denn sein???</p>
<p>Klar ich übergebe ja nur den Wert, der an der Stelle [5][7] steht... Dumm, dumm, dumm... Vielen Dank!</p>
<p>Tut jetzt alles.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211615</guid><dc:creator><![CDATA[hogepoge]]></dc:creator><pubDate>Wed, 17 Jan 2007 20:10:07 GMT</pubDate></item></channel></rss>