Guten Tag,
ich stehe nun vor folgendem Problem:
Ich möchte ein Programm ersellen, was mir 3 verschiedene Zahlen sortiert. Dies hab ich auch schon weitesgend hingekriegt, und nun bin ich bei der Feinarbeit. Also, ich möchte noch folgendes haben:
- ein Randombutton (so das die 3 Felder mit zufälligen Zahlen gefüllt werden)
- die Felder Rechte Seite soll erst Sichtbar sein, wenn man auf sortieren klickt
-> und wenn 2 Zahlen gleichgroß sind, dann soll das Feld "mittlere Zahl" nicht erscheinen.
Nun weiss ich leider nicht, wie ich das realisieren soll.

Dies soll auch alles weitesgehend mit If getan werden.
Hoffe ihr wisst bescheid.
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: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Label1: TLabel; Button_sort: TButton; Panel1: TPanel; Button_end: TButton; Button_zur: TButton; Panel2: TPanel; Panel3: TPanel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; procedure FormCreate(Sender: TObject); procedure Button_endClick(Sender: TObject); procedure Button_zurClick(Sender: TObject); procedure Button_sortClick(Sender: TObject); private public end;
var Form1: TForm1; v_zahl1, v_zahl2, v_zahl3, klein, mittel, gross, nichts : INTEGER;
implementation
{$R *.dfm}
procedure TForm1.Button_endClick(Sender: TObject); begin close; end;
procedure TForm1.Button_zurClick(Sender: TObject); begin Form1.Edit1.Clear; Form1.Edit2.Clear; Form1.Edit3.Clear; Form1.Panel1.Caption := ''; Form1.Panel2.Caption := ''; Form1.Panel3.Caption := ''; v_zahl1 := 0; v_zahl2 := 0; v_zahl3 := 0; klein := 0; gross := 0; mittel:= 0; end;
procedure TForm1.Button_sortClick(Sender: TObject); begin v_zahl1 := strtoint(Form1.Edit1.Text); v_zahl2 := strtoint(Form1.Edit2.Text); v_zahl3 := strtoint(Form1.Edit3.Text);
IF v_zahl1 < v_zahl2 THEN klein := v_zahl1 else klein := v_zahl2; IF klein > v_zahl3 THEN klein := v_zahl3;
IF v_zahl1 > v_zahl2 THEN gross := v_zahl1 ELSE gross := v_zahl2; IF gross < v_zahl3 THEN gross := v_zahl3;
IF (v_zahl1 > v_zahl2) and (v_zahl1 < v_zahl3) THEN mittel := v_zahl1; IF (v_zahl1 > v_zahl3) and (v_zahl1 < v_zahl2) THEN mittel := v_zahl1; IF (v_zahl2 > v_zahl1) and (v_zahl2 < v_zahl3) THEN mittel := v_zahl2; IF (v_zahl2 > v_zahl3) and (v_zahl2 < v_zahl1) THEN mittel := v_zahl2; IF (v_zahl3 > v_zahl2) and (v_zahl3 < v_zahl1) THEN mittel := v_zahl3; IF (v_zahl3 > v_zahl1) and (v_zahl3 < v_zahl2) THEN mittel := v_zahl3;
Form1.Panel1.Caption := inttostr(klein); Form1.Panel2.Caption := inttostr(mittel); Form1.Panel3.Caption := inttostr(gross); end;
procedure TForm1.FormCreate(Sender: TObject); begin
end;
end. |
Bild von dem Programm:
