Autor Beitrag
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 14.05.06 12:20 
Hi Community!
Ich habe ein Programm geschrieben ,das 7 Eingabefelder beinhaltet.
So ich gebe in jedes Feld einen Wert ein, um den Durchschnittswert zu erhalten
rechne ich die Summe der edtEingabe1-edtEingabe7 und teile durch 7.
So zum Problem ich möchte die größte Zahl ausgeben, nur dazu müssen die Eingaben in einen Array eingelesen werden , wie mache ich das am besten?
Danke Im Voraus
Florian
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: So 14.05.06 12:39 
machs am besten so (in die Proc vom Button)

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:
var intarray: array [1..7] of integer;
  Counter,Max: integer;
begin
 try
 intarray[1]:=inttostr(Edit1.Text);
 except
  ShowMessage('Ungültige Eingabe in Feld 1!');
 end;

 try
 intarray[2]:=inttostr(Edit2.Text);
 except
  ShowMessage('Ungültige Eingabe in Feld 2!');
 end;

...

 try
 intarray[7]:=inttostr(Edit7.Text);
 except
  ShowMessage('Ungültige Eingabe in Feld 7!');
 end;

 Max:=0;

 for A:= 1 to 7 do
  if Max<intarray[A] then
    Max:=intarray[A];

 ShowMessage('Das Maximum ist '+inttostr(Max));
end;

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 14.05.06 14:15 
Danke schonmal nur er meldet mir
[Pascal Error] Eingabewerte.pas(66): E2250 There is no overloaded version of 'IntToStr' that can be called with these arguments
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 14.05.06 14:35 
So habs gelöst besten dank ;) beim farbig unterlegten saß der Fehler und A war nicht deklariert
ausblenden volle Höhe 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:
var intarray: array [1..7] of Integer;
Counter,Max,A: Integer;
begin
try
 intarray[1]:=StrToInt(edtEingabe1.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert1!');
 end;


 try
 intarray[2]:=StrToInt(edtEingabe2.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert2!');
 end;

try
 intarray[3]:=StrToInt(edtEingabe3.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert3!');
 end;

   try
 intarray[4]:=StrToInt(edtEingabe4.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert4!');
 end;

 try
 intarray[5]:=StrToInt(edtEingabe5.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert5!');
 end;

 try
 intarray[6]:=StrToInt(edtEingabe6.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert6!');
 end;

 try
 intarray[7]:=StrToInt(edtEingabe7.Text);
 except
  ShowMessage('Ungültige Eingabe bei Wert7!');
 end;
 Max:=0;

 for A:= 1 to 7 do
  if Max<intarray[A] then
    Max:=intarray[A];


 ShowMessage('Der größte Wert ist '+inttostr(Max));

end;