Autor Beitrag
wicked
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: So 03.08.08 20:13 
Hallo,

ich muss in einem StrindGrid das Einmaleins mit zwei verschachtelten repeat-until Scheifen darstellen.. ich weiß allerdings nicht, wie ich diese Schleifen verschachteln soll.. mit der for-to-do schleife habe ich es schon verstanden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.AnzeigenButtonClick(Sender: TObject);
var x,y : integer;
begin
  for y:=1 to 10 do
    for x:=1 to 10 do
     StringGrid1.Cells[x-1,y-1]:=IntToStr(x*y);
end;


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 03.08.08 20:15 
ungefähr so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
x := 1;
repeat
  y := 1;
  repeat
    // machwas mit x und y;
    inc(y);
  until y = 10;
  inc(x);
until x = 10;

_________________
We are, we were and will not be.
wicked Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: So 03.08.08 20:33 
hm, also das versteh ich leider nich.. und es hat auch noch nicht geklappt =(
ich hab mir einfach mal was zusammengeschrieben, was aber auf jeden fall falsch ist.. soweit bin ich eben:(damit rechnet man eigentlich nur die quadratzahlen aus, oder?)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.AnzeigenButtonClick(Sender: TObject);
var x,y : integer;
begin
  x:=0;
  y:=0;
  repeat
    StringGrid1.Cells[x-1,y-1]:=IntToStr(x*y);
    y:=1+y;
    x:=1+x;
  until y>10;
        x>10;
end;


Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 03.08.08 21:02 
so in etwa:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
 x, y: integer;
begin
  x := 0;
 repeat
   y := 0;
  repeat
   StringGrid1.Cells[x, y] := inttostr((x+1)*(y+1));
   inc(y);
  until y > 9;
  inc(x);
 until x > 9;
end;


und verwende bitte das nächste mal die Delphi Tags. Ist einfach besser zu lesen.
wicked Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: So 03.08.08 21:41 
danke, also das funktioniert.. aber ehrlich gesagt, verstehe ich es nicht.. was heißt denn zum beispiel inc(y)?

p.s.: wie verwendet man denn diese tags?
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: So 03.08.08 21:46 
Delphi-Tags verbergen sich hinter dem Knopf "Bereiche". Delphi wählen, text markieren und dann auf "+" klicken.

inc(x); inkrementiert die Variable x um 1, bedeutet also das selbe wie
x := x + 1;

inc(x,2); inkrementiert um 2, also wie x := x + 2; .

dec Dekrementiert entsprechen (um einen Wert vermindern).

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)