<?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[Hallo erstmal.... und c++ code in Mathematica??]]></title><description><![CDATA[<p>hallo allerseits,</p>
<p>leider bin ich des C++ coden nicht so wirklich mächtig (nur basics) und in Mathematica total der Versager <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>trotzdem möchte ich eine Hausarbeit abgeben in der ich in Mathematica einen Sudokusolver programmieren muss</p>
<p>da mathematica ja auch c++ befehle annimmt dachte ich mir ... nimmst einfach nen c++ code... denkste</p>
<p>kann mir jemand helfen dieses kunststück zu vollenden??</p>
<p>hier der code</p>
<p>------------------<br />
#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int start[9][9] =<br />
{<br />
{ 0, 0, 6, 9, 0, 4, 7, 0, 1 },<br />
{ 3, 1, 9, 0, 2, 0, 0, 0, 0 },<br />
{ 0, 0, 0, 1, 5, 0, 0, 6, 2 },<br />
{ 2, 0, 4, 0, 0, 0, 5, 0, 9 },<br />
{ 7, 6, 0, 4, 0, 0, 0, 2, 0 },<br />
{ 0, 0, 0, 0, 0, 0, 0, 0, 4 },<br />
{ 0, 8, 0, 0, 0, 7, 0, 4, 0 },<br />
{ 0, 0, 0, 0, 0, 8, 0, 9, 5 },<br />
{ 0, 0, 2, 0, 0, 0, 3, 0, 0 }<br />
};</p>
<p>bool isfine(int feld[9][9], int x, int y)<br />
{<br />
// doppelte Zahl in Zeile oder Spalte?<br />
for (int yi = 0; yi &lt; 9; yi++)<br />
if (yi != y &amp;&amp; feld[x][yi] == feld[x][y])<br />
return false;<br />
for (int xi = 0; xi &lt; 9; xi++)<br />
if (xi != x &amp;&amp; feld[xi][y] == feld[x][y])<br />
return false;</p>
<p>// Neuner-Kästchen-Test<br />
int x1 = (x / 3) * 3;<br />
int y1 = (y / 3) * 3;<br />
for (int xk = x1; xk &lt; x1 + 3; xk++)<br />
for (int yk = y1; yk &lt; y1 + 3; yk++)<br />
if ((xk != x || yk != y) &amp;&amp; feld[xk][yk] == feld[x][y])<br />
return false;</p>
<p>return true;<br />
}</p>
<p>bool nextone(int feld[9][9], int x, int y)<br />
{<br />
if (y == 9) { y = 0; x++; };<br />
if (x == 9) return true;</p>
<p>if (feld[x][y] &gt; 0)<br />
{<br />
if (!isfine(feld, x, y)) return false;<br />
return nextone(feld, x, y + 1);<br />
}<br />
else for (feld[x][y] = 1; feld[x][y] &lt;= 9; feld[x][y]++)<br />
{<br />
if (!isfine(feld, x, y)) continue;<br />
if (nextone(feld, x, y + 1)) return true;<br />
}<br />
feld[x][y] = 0;<br />
return false;<br />
};</p>
<p>int main(int argc, char **argv)<br />
{<br />
if (nextone(start, 0, 0))<br />
{<br />
for (int x = 0; x &lt; 9; x++)<br />
{<br />
for (int y = 0; y &lt; 9; y++)<br />
cout &lt;&lt; start[x][y];<br />
cout &lt;&lt; endl;<br />
}<br />
}<br />
else<br />
cout &lt;&lt; &quot;Dieses Rätsel ist nicht lösbar!&quot; &lt;&lt; endl;</p>
<p>getchar();<br />
return 0;<br />
}<br />
-----------------</p>
<p>im c++ compiler funktioniert das bestens...</p>
<p>aber wie bringt man sowas in Wolframs Mathematica zum laufen??</p>
<p>wäre für Hilfe dankbar</p>
<p>edit: andere lösungen/codes in mathematica die den selben zweck erfüllen sind mir natürlich auch recht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_savoring_food"
      title=":yum:"
      alt="😋"
    /></p>
<p>Mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/200334/hallo-erstmal-und-c-code-in-mathematica</link><generator>RSS for Node</generator><lastBuildDate>Mon, 29 Jun 2026 08:21:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/200334.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Dec 2007 14:43:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hallo erstmal.... und c++ code in Mathematica?? on Thu, 13 Dec 2007 14:53:34 GMT]]></title><description><![CDATA[<p>hallo allerseits,</p>
<p>leider bin ich des C++ coden nicht so wirklich mächtig (nur basics) und in Mathematica total der Versager <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>trotzdem möchte ich eine Hausarbeit abgeben in der ich in Mathematica einen Sudokusolver programmieren muss</p>
<p>da mathematica ja auch c++ befehle annimmt dachte ich mir ... nimmst einfach nen c++ code... denkste</p>
<p>kann mir jemand helfen dieses kunststück zu vollenden??</p>
<p>hier der code</p>
<p>------------------<br />
#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int start[9][9] =<br />
{<br />
{ 0, 0, 6, 9, 0, 4, 7, 0, 1 },<br />
{ 3, 1, 9, 0, 2, 0, 0, 0, 0 },<br />
{ 0, 0, 0, 1, 5, 0, 0, 6, 2 },<br />
{ 2, 0, 4, 0, 0, 0, 5, 0, 9 },<br />
{ 7, 6, 0, 4, 0, 0, 0, 2, 0 },<br />
{ 0, 0, 0, 0, 0, 0, 0, 0, 4 },<br />
{ 0, 8, 0, 0, 0, 7, 0, 4, 0 },<br />
{ 0, 0, 0, 0, 0, 8, 0, 9, 5 },<br />
{ 0, 0, 2, 0, 0, 0, 3, 0, 0 }<br />
};</p>
<p>bool isfine(int feld[9][9], int x, int y)<br />
{<br />
// doppelte Zahl in Zeile oder Spalte?<br />
for (int yi = 0; yi &lt; 9; yi++)<br />
if (yi != y &amp;&amp; feld[x][yi] == feld[x][y])<br />
return false;<br />
for (int xi = 0; xi &lt; 9; xi++)<br />
if (xi != x &amp;&amp; feld[xi][y] == feld[x][y])<br />
return false;</p>
<p>// Neuner-Kästchen-Test<br />
int x1 = (x / 3) * 3;<br />
int y1 = (y / 3) * 3;<br />
for (int xk = x1; xk &lt; x1 + 3; xk++)<br />
for (int yk = y1; yk &lt; y1 + 3; yk++)<br />
if ((xk != x || yk != y) &amp;&amp; feld[xk][yk] == feld[x][y])<br />
return false;</p>
<p>return true;<br />
}</p>
<p>bool nextone(int feld[9][9], int x, int y)<br />
{<br />
if (y == 9) { y = 0; x++; };<br />
if (x == 9) return true;</p>
<p>if (feld[x][y] &gt; 0)<br />
{<br />
if (!isfine(feld, x, y)) return false;<br />
return nextone(feld, x, y + 1);<br />
}<br />
else for (feld[x][y] = 1; feld[x][y] &lt;= 9; feld[x][y]++)<br />
{<br />
if (!isfine(feld, x, y)) continue;<br />
if (nextone(feld, x, y + 1)) return true;<br />
}<br />
feld[x][y] = 0;<br />
return false;<br />
};</p>
<p>int main(int argc, char **argv)<br />
{<br />
if (nextone(start, 0, 0))<br />
{<br />
for (int x = 0; x &lt; 9; x++)<br />
{<br />
for (int y = 0; y &lt; 9; y++)<br />
cout &lt;&lt; start[x][y];<br />
cout &lt;&lt; endl;<br />
}<br />
}<br />
else<br />
cout &lt;&lt; &quot;Dieses Rätsel ist nicht lösbar!&quot; &lt;&lt; endl;</p>
<p>getchar();<br />
return 0;<br />
}<br />
-----------------</p>
<p>im c++ compiler funktioniert das bestens...</p>
<p>aber wie bringt man sowas in Wolframs Mathematica zum laufen??</p>
<p>wäre für Hilfe dankbar</p>
<p>edit: andere lösungen/codes in mathematica die den selben zweck erfüllen sind mir natürlich auch recht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_savoring_food"
      title=":yum:"
      alt="😋"
    /></p>
<p>Mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1419983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1419983</guid><dc:creator><![CDATA[skalar]]></dc:creator><pubDate>Thu, 13 Dec 2007 14:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to Hallo erstmal.... und c++ code in Mathematica?? on Thu, 13 Dec 2007 15:08:45 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-1581.html" rel="nofollow">Jester</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-43.html" rel="nofollow">Mathematik</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-8.html" rel="nofollow">Rund um die Programmierung</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1420017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1420017</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Thu, 13 Dec 2007 15:08:45 GMT</pubDate></item><item><title><![CDATA[Reply to Hallo erstmal.... und c++ code in Mathematica?? on Thu, 13 Dec 2007 21:00:04 GMT]]></title><description><![CDATA[<p><a href="http://reference.wolfram.com/mathematica/guide/CLanguageInterface.html" rel="nofollow">http://reference.wolfram.com/mathematica/guide/CLanguageInterface.html</a></p>
<p>ich glaube aber nicht das dein lehrer damit zufrieden ist, wenn du aus mathematica einfach eine c++ library aufrufst. so schwierig ist es nicht das in mathematica umzusetzen, versuch es doch erstmal und frag wieder wenn du es nicht hinbekommst und konkrete fragen zu mathematica hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1420211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1420211</guid><dc:creator><![CDATA[borg]]></dc:creator><pubDate>Thu, 13 Dec 2007 21:00:04 GMT</pubDate></item><item><title><![CDATA[Reply to Hallo erstmal.... und c++ code in Mathematica?? on Fri, 14 Dec 2007 13:36:03 GMT]]></title><description><![CDATA[<p>hmm... also soweit ich das verstanden habe können wir c++ benutzen</p>
<p>als tipp steht inder aufgabe</p>
<p>&quot;wichtige mathematica-befehle: integer, Table, random, if, for, deletecases, do, append, print</p>
<p>wie gesagt.... in mathematica bin ich ne totale niete... und eiegntlcih werde ich es auch nach dieser hausarbeit nicht mehr brauchen..</p>
<p>deswegen wäre ich für lösungswege sehr dankbar</p>
<p>:xmas1:</p>
<p>edit: &quot;sudokusolve&quot; dürfen wir leider net benutzten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ....</p>
<p>edit2: genau DIESEN code in mathematica einfügen wollte ich eigentlich net... ich dachte eigentlich das man in mathematica mit kleineren änderungen ein normales notebook daraus machen kann <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/1420536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1420536</guid><dc:creator><![CDATA[skalar]]></dc:creator><pubDate>Fri, 14 Dec 2007 13:36:03 GMT</pubDate></item><item><title><![CDATA[Reply to Hallo erstmal.... und c++ code in Mathematica?? on Fri, 14 Dec 2007 15:31:16 GMT]]></title><description><![CDATA[<p>skalar schrieb:</p>
<blockquote>
<p>ich dachte eigentlich das man in mathematica mit kleineren änderungen ein normales notebook daraus machen kann <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>
</blockquote>
<p>ja dann auf! eine liste der befehle die du dafür brauchst hast du ja schon. mathematica hat eine wirklich gute doku, wenn du dich dort eingearbeitet hättest und sofort angefangen hättest, anstatt dich in mehreren foren (<a href="http://www.matheraum.de/read?t=339972" rel="nofollow">http://www.matheraum.de/read?t=339972</a>) anzumelden und zu fragen ob jemand für dich deine hausaufgaben macht, wärst du schon fertig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1420613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1420613</guid><dc:creator><![CDATA[borg]]></dc:creator><pubDate>Fri, 14 Dec 2007 15:31:16 GMT</pubDate></item></channel></rss>