Autor Beitrag
dinu_ch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Mo 20.10.03 21:28 
hallo

ich bastle da newbie-mässig in delphi ein lotto-programm zusammen und möchte arrys verwenden, der anfang sieht so aus :

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:
67:
68:
program lotto; 

{$APPTYPE CONSOLE} 

uses 
SysUtils; 

// Prozedru zum Check ob Text oder Zahl 

procedure readint(var x:integer); 

var 
str : string//Eingabevariable 
inp,code : integer; // Umwandlungsvariable 

begin 
repeat 
readln(str); 
val(str,x,code); 
if (code <> 0then Write(' Keine Zahl eingegeben - nochmals : '
until (code = 0); 
end

var 
arr:array[1..7 ] of integer; 
arrz:array[1..6 ] of integer; 
i,j:integer; 

begin 

// Zahlen ziehen 

randomize; 
repeat 
for i:=1 to 7 do 
arr[i]:=random(49)+1
until (arr[1] <> arr[2]) and (arr[1] <> arr[3]) and 
(arr[1] <> arr[4]) and (arr[1] <> arr[5]) and 
(arr[1] <> arr[6]) and (arr[2] <> arr[3]) and 
(arr[2] <> arr[4]) and (arr[2] <> arr[5]) and 
(arr[2] <> arr[6]) and (arr[3] <> arr[4]) and 
(arr[3] <> arr[5]) and (arr[3] <> arr[6]) and 
(arr[4] <> arr[5]) and (arr[4] <> arr[6]) and 
(arr[5] <> arr[6]) and (arr[1] <> arr[7]) and 
(arr[2] <> arr[7]) and (arr[3] <> arr[7]) and 
(arr[4] <> arr[7]) and (arr[5] <> arr[7]) and 
(arr[6] <> arr[7]); 
writeln; 
writeln(' Lottozahlen : ',arr[1],' ',arr[2],' ',arr[3],' ',arr[4],' ',arr[5],' ',arr[6]); 
writeln(' Zusatzzahl : ',arr[7]); 
readln; 


// Tippen 

begin 
for j := 1 to 6 do 
begin 
write(' Geben Sie die ' +IntToStr(j)+ '.Zahl ein : '); 
readint(arrz[j]); //Eingabe des i-Wertes in Array 
end

// Ausgabe Tips 

writeln(arrz[1],' ',arrz[2],' ',arrz[3],' ',arrz[4],' ',arrz[5],' ',arrz[6]); 
end
readln; 
end.



- Dass ich die arr[i] vergleiche sieht ziemlich hässlich aus, gibt es da eine Alternative ?
- Und wie kann ich beim arrz[j] verhindern, dass 2x das gleiche eingegeben wird ?

Grüsse

dinu_ch

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.
Shark
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Di 21.10.03 12:11 
Arbeite bei Deinem Problem mit Mengen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
type
  TLottoNum = 1..49;
type
  TLottoSet = set of TLottoNum;

var Set1: TLottoSet;

Set1 := [367193039];


mit in kannst Du nachschauen ob eine Zahl in Deiner Menge ist:

ausblenden Delphi-Quelltext
1:
if 5 in Set1 then...					


Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt und "von Hand" Formatierung entfernt.
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Di 21.10.03 16:45 
Schon wieder so ein cross poster :evil: www.delphipraxis.net...ays+vergleichen.html

böse, böse!

_________________
mfg.
mâximôv