Einzelnen Beitrag anzeigen

Christian H.

Registriert seit: 22. Mär 2006
9 Beiträge
 
#7

Re: Sudoku Programm !?

  Alt 23. Mär 2006, 13:55
Danke für die vielen Informationen ! Ich poste einfach mal meinen code den ich bisher habe ! Mir ist durchaus klar , das der Code noch relativ umständlich ist ! Zwar sind mir die Grundlagen einigermassen klar (Schleifen , Arrays u.s.w) Allerindgs hatte ich mir vorgenommen das programm erstmal möglichst verständlich zu programmieren auch wenn es mehr schreibarbeit ist und dann im nachinein noch zu vereinfachen !

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);

begin

  Label1.caption := IntToStr (A1);
  Label2.caption := IntToStr (A2);
  Label3.caption := IntToStr (A3);
  Label4.caption := IntToStr (A4);
  Label5.caption := IntToStr (A5);
  Label6.caption := IntToStr (A6);
  Label7.caption := IntToStr (A7);
  Label8.caption := IntToStr (A8);
  Label9.caption := IntToStr (A9);

  Label10.caption := IntToStr (B1);
  Label11.caption := IntToStr (B2);
  Label12.caption := IntToStr (B3);
  Label13.caption := IntToStr (B4);
  Label14.caption := IntToStr (B5);
  Label15.caption := IntToStr (B6);
  Label16.caption := IntToStr (B7);
  Label17.caption := IntToStr (B8);
  Label18.caption := IntToStr (B9);

  Label19.caption := IntToStr (C1);
  Label20.caption := IntToStr (C2);
  Label21.caption := IntToStr (C3);
  Label22.caption := IntToStr (C4);
  Label23.caption := IntToStr (C5);
  Label24.caption := IntToStr (C6);
  Label25.caption := IntToStr (C7);
  Label26.caption := IntToStr (C8);
  Label27.caption := IntToStr (C9);

  Label28.caption := IntToStr (D1);
  Label29.caption := IntToStr (D2);
  Label30.caption := IntToStr (D3);
  Label31.caption := IntToStr (D4);
  Label32.caption := IntToStr (D5);
  Label33.caption := IntToStr (D6);
  Label34.caption := IntToStr (D7);
  Label35.caption := IntToStr (D8);
  Label36.caption := IntToStr (D9);

  Label55.caption := IntToStr (G1);
  Label56.caption := IntToStr (G2);
  Label57.caption := IntToStr (G3);
  Label58.caption := IntToStr (G4);
  Label59.caption := IntToStr (G5);
  Label60.caption := IntToStr (G6);
  Label61.caption := IntToStr (G7);
  Label62.caption := IntToStr (G8);
  Label63.caption := IntToStr (G9);

  A1 := random (9)+1;
  begin;
  Repeat
  A2 := random (9)+1;
  Until
  A2 <> A1
  end;

  begin
  Repeat
  A3 := random (9)+1;
  Until
  (A3 <> A1) and (A3 <> A2)
  end;

  begin
  Repeat
  B1 := random (9)+1;
  Until
  (B1 <> A1) and (B1 <> A2) and (B1 <> A3)
  end;

  begin
  Repeat
  B2 := random (9)+1;
  Until
  (B2 <> A1) and (B2 <> A2) and (B2 <> A3) and (B2 <> B1)
  end;

  begin
  Repeat
  B3 := random (9)+1;
  Until
  (B3 <> A1) and (B3 <> A2) and (B3 <> A3) and (B3 <> B1) and (B3 <> B2)
  end;

  begin
  Repeat
  C1 := random (9)+1;
  Until
  (C1 <> A1) and (C1 <> A2) and (C1 <> A3) and (C1 <> B1) and (C1 <> B2) and (C1 <> B3)
  end;

  begin
  Repeat
  C2 := random (9)+1;
  Until
  (C2 <> A1) and (C2 <> A2) and (C2 <> A3) and (C2 <> B1) and (C2 <> B2) and (C2 <> B3) and (C2 <> C1)
  end;

  begin
  Repeat
  C3 := random (9)+1;
  Until
  (C3 <> A1) and (C3 <> A2) and (C3 <> A3) and (C3 <> B1) and (C3 <> B2) and (C3 <> B3) and (C3 <> C1) and (C3 <> C2)
  end;


  begin
  Repeat
  A4 := random (9)+1;
  Until
  (A4 <> A1) and (A4 <> A2) and (A4 <> A3)
  end;

  begin
  Repeat
  A5 := random (9)+1;
  Until
  (A5 <> A1) and (A5 <> A2) and (A5 <> A3) and (A5 <> A4)
  end;

  begin
  Repeat
  A6 := random (9)+1;
  Until
  (A6 <> A1) and (A6 <> A2) and (A6 <> A3) and (A6 <> A4) and (A6 <> A5)
  end;

  begin
  Repeat
  B4 := random (9)+1;
  Until
  (B4 <> A4) and (B4 <> A5) and (B4 <> A6) and (B4 <> B1) and (B4 <> B2) and (B4 <> B3)
  end;

  begin
  Repeat
  B5 := random (9)+1;
  Until
  (B5 <> A4) and (B5 <> A5) and (B5 <> A6) and (B5 <> B1) and (B5 <> B2) and (B5 <> B3) and (B5 <> B4)
  end;

  begin
  Repeat
  B6 := random (9)+1;
  Until
  (B6 <> A4) and (B6 <> A5) and (B6 <> A6) and (B6 <> B1) and (B6 <> B2) and (B6 <> B3) and (B6 <> B4) and (B6 <> B5)
  end;

  begin
  Repeat
  C4 := random (9)+1;
  Until
  (C4 <> A4) and (C4 <> A5) and (C4 <> A6) and (C4 <> B4) and (C4 <> B5) and (C4 <> B6) and (C4 <> C1) and (C4 <> C2) and (C4 <> C3)
  end;

  begin
  Repeat
  C5 := random (9)+1;
  Until
  (C5 <> A4) and (C5 <> A5) and (C5 <> A6) and (C5 <> B4) and (C5 <> B5) and (C5 <> B6) and (C5 <> C1) and (C5 <> C2) and (C5 <> C3) and (C5 <> C4)
  end;

  {begin
  Repeat
  C6 := random (9)+1;
  Until
  (C6 <> A4) and (C6 <> A5) and (C6 <> A6) and (C6 <> B4) and (C6 <> B5) and (C6 <> B6) and (C6 <> C1) and (C6 <> C2) and (C6 <> C3) and (C6 <> C4) and (C6 <> C5)
  end;}


  end;

end.
So wie es momentan ist klapt das Programm einbandfrei ! Sobald ich aber die letzte Zeile die als Kommentatr gesetzt ist ausklammert stürzt das programm ab !

mfg
  Mit Zitat antworten Zitat