<?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[Bitte um Hilfe bei Sudoku Programm]]></title><description><![CDATA[<p>Hallo</p>
<p>Von der Uni aus sollen wir ein Sudoku Solver schreiben, viel quelltext ist schon vorgegeben, aber leider nicht alles. Ich gebe euch mal vor, was vorgebenen ist, dazukommen sollen die Teile bei den // ** INSERT ** // und die funktionen korrekt und weiter</p>
<p>Leider habe ich gar keinen plan, wie das gehen soll</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;

struct sud
{ char mat[9][9][10];
       // m[i][j][k] Feld Element
       //   i = {0..8} Zeilen Index
	   //   j = {0..8} Spalten Index
	   //
	   // m[i][j][0]
	   //  := 0     : Feldwert offen
	   //  := {1..9}: Feldwert fest
	   //
	   //          m :={1..9}
	   // m[i][j][m] Feldwert
	   //  := 0    == m möglich
	   //  := 1    == m verboten  
  char next[3];
       // Test-Element-Parameter
	   // next[0] := Zeile
	   // next[1] := Spalte
	   // next[2] := Wert

};

typedef struct sud SUDOK;

int start(SUDOK *res);
void ausgabe(SUDOK *res);
void ausschluss(SUDOK *res);
int einzeln(SUDOK *res);
int probe (SUDOK *alt);
int weiter(SUDOK *neu);
int korrekt(SUDOK *neu);

// Hauptfunktion

int main(void)
{ SUDOK res ={{0}};
  int i,j;

  printf(&quot; Willkommen zum Sudoku-Programm \n\n\n&quot;);

  start(&amp;res);

  printf(&quot; __Originalmatrix: __&quot;);
  ausgabe(&amp;res);
  printf(&quot; ^^Originalmatrix: ^^&quot;);

  printf(&quot;\n\n\n &quot;);

  for (i=0; i&lt;9; i++)
	  for (j=0; j&lt;9; j++)
		  { res.next[0] = i;
	        res.next[1] = j;
			res.next[2] = res.mat[i][j][0];
			ausschluss(&amp;res);
		  }

  ausgabe(&amp;res);

  res.next[0]=res.next[1]=res.next[2] = 0;
  probe(&amp;res);

  return(-100);

}

// Startwertfunktion:

int start(SUDOK *res)    //Vorgaben festlegen
{ char i,j;
  char vor[9][9] =
    { 0, 7, 0,   6, 0, 0,   0, 8, 0,
	  6, 0, 0,   5, 0, 0,   0, 0, 0,
	  0, 0, 9,   0, 0, 4,   0, 5, 0,

	  1, 2, 0,   0, 0, 0,   9, 6, 0,
	  0, 0, 0,   0, 2, 0,   4, 0, 0,
	  0, 0, 6,   0, 0, 0,   0, 0, 0,

	  0, 0, 0,   4, 3, 0,   1, 0, 7,
	  2, 0, 5,   1, 0, 0,   0, 0, 0,
	  0, 0, 0,   0, 0, 0,   8, 0, 0

    };

  for (i=0; i&lt;9; i++)
	  for (j=0; j&lt;9; j++)
		  res-&gt;mat[i][j][0] = vor [i][j];

  return(0);

}

// Ausgabe der Matrix

void ausgabe(SUDOK *res)
  { char i,j;

  for (i=0; i&lt;9; i++)
	  { printf(&quot;\n &quot;);
        if ((i==3)||(i==6))
		   printf(&quot;\n &quot;);

		for(j=0; j&lt;9; j++)
			{ if ((j==3)||(j==6))
		         printf(&quot; &quot;);

			  if (res-&gt;mat[i][j][0] != 0)
				 printf(&quot;%2d&quot;,res-&gt;mat[i][j][0]);
	          else printf(&quot; .&quot;);
		    }
	  }
  printf(&quot;\n&quot;);
  return;
}

// Ausschluss-Funktion
// Eindeutige Vorgaben löschen Möglichkeiten in
// Zeile Spalte und Block

void ausschluss(SUDOK *res)
{ char i, j, k, m, n, r, s;
  if (res-&gt;next[2] == 0)
	  return;

  i = res-&gt;next[0];
  j = res-&gt;next[1];
  k = res-&gt;next[2];

  for (m=0; m&lt;9; m++)         // Ausschluss Werte: Spalte
	  res-&gt;mat[m][j][k] = 1;

  for (n=0; n&lt;9; n++)         // Ausschluss Werte: Zeile
	  res-&gt;mat[i][n][k] = 1;

  r = i/3;
  s = j/3;

  for (m=0; m&lt;3; m++)         // Ausschluss Werte: Block
	  for (n=0; n&lt;3; n++)
		  res-&gt;mat[m+r*3][n+s*3][k] = 1;

  for (m=1; m&lt;10; m=m+1)
	  res-&gt;mat[i][j][m] = 1;

  res-&gt;mat[i][j][k] = 0;
  res-&gt;mat[i][j][0] = k;

  return;

}

// Einzeln-Funktion
// Diese Funktion sucht nach Feldern mit nur einer Möglichkeit
// Das Feld Next bekommt diese Werte übergeben
// Bei Negativ endet sie mit 0

int einzeln(SUDOK *res)
{ int i, j, k, kneu, n;
  for (i=0; i&lt;9; i++)
  { for (j=0; j&lt;9; j++)
    { if(res-&gt;mat[i][j][0])
	  continue;

	  n=0;
	  for (k=1; k&lt;10; k++)
	  { if(res-&gt;mat[i][j][k]==0)
        { n = n+1;
		  kneu = k;
        }
      }
      if (n==1)
	  { res-&gt;next[0] = i;
        res-&gt;next[1] = j;
		res-&gt;next[2] = kneu;
		return(1);
      }
    }
  }
  return(0);
}

int probe (SUDOK *alt)
{ SUDOK neu;
  char i,ip, j,jp, k,kp, korr =-1;
  static int s =0;

  i = alt-&gt;next[0];
  j = alt-&gt;next[1];
  k = alt-&gt;next[2];

  neu = *alt;

  printf(&quot; %d %d %d &quot;, i,j,k);

ip=jp=0;

  do{
         // INSERT //

            {

			  do { ausschluss(&amp;neu);
				 } while (einzeln(&amp;neu));

         // INSERT //

				 }
            }

			if (ip || kp || jp )
				korr = korrekt(&amp;neu);

			if (korr &gt; 0)
			{ printf(&quot; Lösung gefunden!!!&quot;);  //Lösung richtig
	          ausgabe(&amp;neu);
		      break;
		    }

            if (korr &lt; 0)
		    { neu = *alt;
		      if( (weiter(&amp;neu) == 0) || (i != neu.next[0]) || (j != neu.next[1])) break;

              k = alt-&gt;next[2] = neu.next[2];
			  continue;
		    }

            do { if( weiter(&amp;neu) == 0) return(s);
			   } while (i == neu.next[0] &amp;&amp; j == neu.next[1]);

			probe(&amp;neu);
			neu = *alt;
			if (weiter(&amp;neu) == 0) return(s);

            k = alt-&gt;next[2] = neu.next[2];

   } while ( (i == neu.next[0]) &amp;&amp; (j == neu.next[1]));

  return(s);

}
</code></pre>
<p>Wäre super wenn ihr mir sagen könntet wie ich den Quelltext vervollständigen kann, damit das Programm läuft.</p>
<p>Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182129/bitte-um-hilfe-bei-sudoku-programm</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 00:29:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182129.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 May 2007 18:27:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Mon, 21 May 2007 18:27:06 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Von der Uni aus sollen wir ein Sudoku Solver schreiben, viel quelltext ist schon vorgegeben, aber leider nicht alles. Ich gebe euch mal vor, was vorgebenen ist, dazukommen sollen die Teile bei den // ** INSERT ** // und die funktionen korrekt und weiter</p>
<p>Leider habe ich gar keinen plan, wie das gehen soll</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;

struct sud
{ char mat[9][9][10];
       // m[i][j][k] Feld Element
       //   i = {0..8} Zeilen Index
	   //   j = {0..8} Spalten Index
	   //
	   // m[i][j][0]
	   //  := 0     : Feldwert offen
	   //  := {1..9}: Feldwert fest
	   //
	   //          m :={1..9}
	   // m[i][j][m] Feldwert
	   //  := 0    == m möglich
	   //  := 1    == m verboten  
  char next[3];
       // Test-Element-Parameter
	   // next[0] := Zeile
	   // next[1] := Spalte
	   // next[2] := Wert

};

typedef struct sud SUDOK;

int start(SUDOK *res);
void ausgabe(SUDOK *res);
void ausschluss(SUDOK *res);
int einzeln(SUDOK *res);
int probe (SUDOK *alt);
int weiter(SUDOK *neu);
int korrekt(SUDOK *neu);

// Hauptfunktion

int main(void)
{ SUDOK res ={{0}};
  int i,j;

  printf(&quot; Willkommen zum Sudoku-Programm \n\n\n&quot;);

  start(&amp;res);

  printf(&quot; __Originalmatrix: __&quot;);
  ausgabe(&amp;res);
  printf(&quot; ^^Originalmatrix: ^^&quot;);

  printf(&quot;\n\n\n &quot;);

  for (i=0; i&lt;9; i++)
	  for (j=0; j&lt;9; j++)
		  { res.next[0] = i;
	        res.next[1] = j;
			res.next[2] = res.mat[i][j][0];
			ausschluss(&amp;res);
		  }

  ausgabe(&amp;res);

  res.next[0]=res.next[1]=res.next[2] = 0;
  probe(&amp;res);

  return(-100);

}

// Startwertfunktion:

int start(SUDOK *res)    //Vorgaben festlegen
{ char i,j;
  char vor[9][9] =
    { 0, 7, 0,   6, 0, 0,   0, 8, 0,
	  6, 0, 0,   5, 0, 0,   0, 0, 0,
	  0, 0, 9,   0, 0, 4,   0, 5, 0,

	  1, 2, 0,   0, 0, 0,   9, 6, 0,
	  0, 0, 0,   0, 2, 0,   4, 0, 0,
	  0, 0, 6,   0, 0, 0,   0, 0, 0,

	  0, 0, 0,   4, 3, 0,   1, 0, 7,
	  2, 0, 5,   1, 0, 0,   0, 0, 0,
	  0, 0, 0,   0, 0, 0,   8, 0, 0

    };

  for (i=0; i&lt;9; i++)
	  for (j=0; j&lt;9; j++)
		  res-&gt;mat[i][j][0] = vor [i][j];

  return(0);

}

// Ausgabe der Matrix

void ausgabe(SUDOK *res)
  { char i,j;

  for (i=0; i&lt;9; i++)
	  { printf(&quot;\n &quot;);
        if ((i==3)||(i==6))
		   printf(&quot;\n &quot;);

		for(j=0; j&lt;9; j++)
			{ if ((j==3)||(j==6))
		         printf(&quot; &quot;);

			  if (res-&gt;mat[i][j][0] != 0)
				 printf(&quot;%2d&quot;,res-&gt;mat[i][j][0]);
	          else printf(&quot; .&quot;);
		    }
	  }
  printf(&quot;\n&quot;);
  return;
}

// Ausschluss-Funktion
// Eindeutige Vorgaben löschen Möglichkeiten in
// Zeile Spalte und Block

void ausschluss(SUDOK *res)
{ char i, j, k, m, n, r, s;
  if (res-&gt;next[2] == 0)
	  return;

  i = res-&gt;next[0];
  j = res-&gt;next[1];
  k = res-&gt;next[2];

  for (m=0; m&lt;9; m++)         // Ausschluss Werte: Spalte
	  res-&gt;mat[m][j][k] = 1;

  for (n=0; n&lt;9; n++)         // Ausschluss Werte: Zeile
	  res-&gt;mat[i][n][k] = 1;

  r = i/3;
  s = j/3;

  for (m=0; m&lt;3; m++)         // Ausschluss Werte: Block
	  for (n=0; n&lt;3; n++)
		  res-&gt;mat[m+r*3][n+s*3][k] = 1;

  for (m=1; m&lt;10; m=m+1)
	  res-&gt;mat[i][j][m] = 1;

  res-&gt;mat[i][j][k] = 0;
  res-&gt;mat[i][j][0] = k;

  return;

}

// Einzeln-Funktion
// Diese Funktion sucht nach Feldern mit nur einer Möglichkeit
// Das Feld Next bekommt diese Werte übergeben
// Bei Negativ endet sie mit 0

int einzeln(SUDOK *res)
{ int i, j, k, kneu, n;
  for (i=0; i&lt;9; i++)
  { for (j=0; j&lt;9; j++)
    { if(res-&gt;mat[i][j][0])
	  continue;

	  n=0;
	  for (k=1; k&lt;10; k++)
	  { if(res-&gt;mat[i][j][k]==0)
        { n = n+1;
		  kneu = k;
        }
      }
      if (n==1)
	  { res-&gt;next[0] = i;
        res-&gt;next[1] = j;
		res-&gt;next[2] = kneu;
		return(1);
      }
    }
  }
  return(0);
}

int probe (SUDOK *alt)
{ SUDOK neu;
  char i,ip, j,jp, k,kp, korr =-1;
  static int s =0;

  i = alt-&gt;next[0];
  j = alt-&gt;next[1];
  k = alt-&gt;next[2];

  neu = *alt;

  printf(&quot; %d %d %d &quot;, i,j,k);

ip=jp=0;

  do{
         // INSERT //

            {

			  do { ausschluss(&amp;neu);
				 } while (einzeln(&amp;neu));

         // INSERT //

				 }
            }

			if (ip || kp || jp )
				korr = korrekt(&amp;neu);

			if (korr &gt; 0)
			{ printf(&quot; Lösung gefunden!!!&quot;);  //Lösung richtig
	          ausgabe(&amp;neu);
		      break;
		    }

            if (korr &lt; 0)
		    { neu = *alt;
		      if( (weiter(&amp;neu) == 0) || (i != neu.next[0]) || (j != neu.next[1])) break;

              k = alt-&gt;next[2] = neu.next[2];
			  continue;
		    }

            do { if( weiter(&amp;neu) == 0) return(s);
			   } while (i == neu.next[0] &amp;&amp; j == neu.next[1]);

			probe(&amp;neu);
			neu = *alt;
			if (weiter(&amp;neu) == 0) return(s);

            k = alt-&gt;next[2] = neu.next[2];

   } while ( (i == neu.next[0]) &amp;&amp; (j == neu.next[1]));

  return(s);

}
</code></pre>
<p>Wäre super wenn ihr mir sagen könntet wie ich den Quelltext vervollständigen kann, damit das Programm läuft.</p>
<p>Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289343</guid><dc:creator><![CDATA[McSeth]]></dc:creator><pubDate>Mon, 21 May 2007 18:27:06 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Mon, 21 May 2007 18:42:09 GMT]]></title><description><![CDATA[<p>wozu gehst du zur uni, wenn du nix tun willst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289356</guid><dc:creator><![CDATA[knarz]]></dc:creator><pubDate>Mon, 21 May 2007 18:42:09 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Mon, 21 May 2007 18:43:51 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>sollen wir jetzt raten oder auswürfeln was da noch fehlt? Wo sind deine Anfänge/Vermutungen? Wir machen hier für dich nicht Hausaufgaben, wir geben dir nur Hilfe zur Felbsthilfe. Und da du auch nichts C++ spezifisches gepostet hast wirst du sicher auch erstmal ins Ansi-C Forum verschoben.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289358</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Mon, 21 May 2007 18:43:51 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Mon, 21 May 2007 18:44:40 GMT]]></title><description><![CDATA[<p>hmm..nette antwort danke</p>
<p>1. studiere ich kein informatik, es ist also nur ein nebenfach was wir belegen müssen<br />
2. sitze ich seit mehreren tagen daran, und versuche auf des rätsels lösung zu kommen</p>
<p>und last but not least 3.<br />
Hilft mir deine Antwort leider kein bißchen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289359</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289359</guid><dc:creator><![CDATA[McSeth]]></dc:creator><pubDate>Mon, 21 May 2007 18:44:40 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Mon, 21 May 2007 18:46:57 GMT]]></title><description><![CDATA[<p>Tja Vermutung:</p>
<p>Also im Grunde siehts so aus: Der Teil der Fehlt sieht so aus das ein element was noch möglich wäre genommen wird, und dann wird durchprobiert, und dann wieder eins genommen und so weiter.<br />
und wenn das nicht klappt, stellt man alles auf anfang zurück und versucht es mit anderen werten</p>
<p>die weiterfunktion gibt dabei &quot;wahrscheinlich&quot; an mit welchem element weiter gemacht wird, bzw ob noch möglichkeiten vorhanden sind</p>
<p>die korrekt funktion schaut nach ob das vollständig eingetragene sudoku korrekt ist ob es fehler gibt</p>
<p>in der theroie ist es mir also bekannt aber ich kriegs nicht hin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289362</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289362</guid><dc:creator><![CDATA[McSeth]]></dc:creator><pubDate>Mon, 21 May 2007 18:46:57 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Mon, 21 May 2007 19:06:12 GMT]]></title><description><![CDATA[<p>McSeth schrieb:</p>
<blockquote>
<p>1. studiere ich kein informatik, es ist also nur ein nebenfach was wir belegen müssen</p>
</blockquote>
<p>was du hier schreibst hört sich eher nach null plan von garnix und null bock an. ihr bekommt sicher nicht so eine aufgabe ohne vorbereitung.</p>
<blockquote>
<p>2. sitze ich seit mehreren tagen daran, und versuche auf des rätsels lösung zu kommen</p>
</blockquote>
<p>dann zeig doch mal, was du schon versucht hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289378</guid><dc:creator><![CDATA[knarz]]></dc:creator><pubDate>Mon, 21 May 2007 19:06:12 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Tue, 22 May 2007 05:39:34 GMT]]></title><description><![CDATA[<p>McSeth schrieb:</p>
<blockquote>
<p>1. studiere ich kein informatik, es ist also nur ein nebenfach was wir belegen müssen</p>
</blockquote>
<p>Mein Beileid. Wer hätte denn auch ahnen können, dass man für die Leistungsnachweise im Nebenfach Leistung erbringen muss?! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289530</guid><dc:creator><![CDATA[Gregor]]></dc:creator><pubDate>Tue, 22 May 2007 05:39:34 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Thu, 24 May 2007 18:54:18 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe das gleiche problem mit dem sudoku programm.<br />
@McSeth: hast du schon ne lösung dazu? und du studierst nicht zufällig in brandenburg?</p>
<p>cu Paul12</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291686</guid><dc:creator><![CDATA[Paul12]]></dc:creator><pubDate>Thu, 24 May 2007 18:54:18 GMT</pubDate></item><item><title><![CDATA[Reply to Bitte um Hilfe bei Sudoku Programm on Sun, 27 May 2007 20:04:25 GMT]]></title><description><![CDATA[<p>knarz schrieb:</p>
<blockquote>
<p>McSeth schrieb:</p>
<blockquote>
<p>1. studiere ich kein informatik, es ist also nur ein nebenfach was wir belegen müssen</p>
</blockquote>
<p>was du hier schreibst hört sich eher nach null plan von garnix und null bock an. ihr bekommt sicher nicht so eine aufgabe ohne vorbereitung.</p>
</blockquote>
<p>Nur noch so nebenbei: Eine Aufgabenstellung an ner Uni gibts immer OHNE vorbereitung dazu...</p>
<p>da gibts das nächste Übungsblatt, meistens noch nichtmal persönlich ausgeteilt, sondern steht auf de internetseite, hat mit der aktuellen Vorlesung gar nichts zu tun, und es einzigst was man dazu weiß ist.</p>
<p>&quot;Deadline: ....&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293354</guid><dc:creator><![CDATA[Spitfire85]]></dc:creator><pubDate>Sun, 27 May 2007 20:04:25 GMT</pubDate></item></channel></rss>