Autor Beitrag
FlaVa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: So 21.05.06 21:28 
hey,

ich hab ne frage... ich hab hier ein Programm geschrieben bzw. 2 in einem und jetzt hab ich ne frage zu der repeatschleife... kann man die irgendwie in if then schleife umschreiben? oder habt ihr ne idee wo ich irgendwo ne if then bedingung einbauen kann!? m[/delphi]fg FlaVa


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
 procedure TForm1.Button1Click(Sender: TObject);


//Deklaration

Var a,b,ausgabe : Integer;


  Begin

  //Initialsierung
  a := strtoint(edit1.text); //speichert den Inhalt von edit1 in die Variable a
  b := strtoint(edit2.text); //speichert den Inhalt von edit2 in die Variable b
  ausgabe := 1;

 
  repeat
      begin

 
     //Berechnung
      a := a * b;
      b := b - 1;

  

     // Ausgabe
     memo1.lines.add(inttostr(ausgabe)+'. Ableitung : f(x)='+inttostr(a)+'*xˆ'+inttostr(b));
     ausgabe:=ausgabe+1;


      end;
  until b = 0;



  end;




procedure TForm1.Button2Click(Sender: TObject);

var x,y,a,b:integer;

     begin
     randomize;
     x := Random(10)+1;
     y := Random(10)+1;

     Memo2.text:=inttostr(x);
     Memo3.text:=inttostr(y);



     end;


procedure TForm1.Button3Click(Sender: TObject);
          begin
          Memo1.text := ('');
          end;



end.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 21.05.06 21:38 
Also erstens gibt es keine If-Schleifen. Und zu deiner Frage: Ich verstehe nicht wie du das mit einer If-Anweisung lösen willst. alternativ könntest du es mit einer While-Schelife lösen.

_________________
Markus Kinzler.
FlaVa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: So 21.05.06 21:41 
ok dann gehts wohl nicht ^^ danke trotzzzzzdem :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 21.05.06 21:42 
Was hattest du vor, warum willst du die Repaet-Schleife ersetzten?

_________________
Markus Kinzler.
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: So 21.05.06 22:13 
user profile iconFlaVa hat folgendes geschrieben:
oder habt ihr ne idee wo ich irgendwo ne if then bedingung einbauen kann!?


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
procedure TForm1.Button1Click(Sender: TObject);
Var a,b,ausgabe : Integer;
Begin
 if not ((Edit1.text='') And (Edit2.text='')) then
 begin
  a := strtoint(edit1.text); //speichert den Inhalt von edit1 in die Variable a
  b := strtoint(edit2.text); //speichert den Inhalt von edit2 in die Variable b
  ausgabe := 1;
  repeat //Berechnung
   a := a * b;
   b := b - 1; // Ausgabe
   memo1.lines.add(inttostr(ausgabe)+'. Ableitung : f(x)='+inttostr(a)+'*xˆ'+inttostr(b));
   ausgabe:=ausgabe+1;
  until b = 0;
 end
 else Showmessage('Bitte gültige Zahlen eingeben');
end;


procedure TForm1.Button2Click(Sender: TObject);
var x,y:integer; //die Variablen a und b brauchst du hier nicht
begin
 randomize;
 x := Random(10)+1;
 y := Random(10)+1;
 Memo2.text:=inttostr(x); //hier langt ein normales Edit-Feld
 Memo3.text:=inttostr(y);
end;


procedure TForm1.Button3Click(Sender: TObject);
begin
 Memo1.text := ('');
end;