bonjour
je voudrais faire une suite combinaison de 4 chiffres avec les nombres 1 a 70
exemple 1234 1235 1236 1237 ect..
donc comment faire une boucle pour la création et avoir une idée du nombre de combinaison
merci de votre aide
bonjour
je voudrais faire une suite combinaison de 4 chiffres avec les nombres 1 a 70
exemple 1234 1235 1236 1237 ect..
donc comment faire une boucle pour la création et avoir une idée du nombre de combinaison
merci de votre aide
Bonjour,
Deux pistes :
- un site ici pour calculer le nombre de tirages ;
- pour faire une boucle : for i := 1 to 4 do begin {ton code ici} end;
Delphi 5 Pro - Delphi 11.3 Alexandria Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
. Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !
Bonjour,
avec 4 chiffres pris parmi 7, il doit y avoir 35 combinaisons ( n! / k! / (n-k)! avec n=7 et k=3)
si l'ordre compte cela doit faire 840 (n! / (n-k)!)
A+
Charly
bonjour
merci pour votre aide
mais je viens de trouver sur un site ma solution
je joint le code que j'ai modifier legerement
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 procedure TForm1.Button1Click(Sender: TObject); var i, j, k, l, m, n, nnpg, nnds, sto: integer; COMBI:string[20]; fil:textfile; begin assignfile(fil,'file.txt'); rewrite(fil); nnds := 70; sto := 0; ListBox1.Clear; for i := 1 to nnds do for j := i to nnds do for k := j to nnds do for l := k to nnds do if ((i <> j) and (i <> k) and (i <> l)) and ((j <> i) and (j <> k) and (j <> l)) and ((k <> i) and (k <> j) and (k <> l)) and ((l <> i) and (l <> j) and (l <> k)) then begin sto := sto + 1; COMBI := IntToStr(i) + ';' + IntToStr(j) + ';' + IntToStr(k) + ';' + IntToStr(l); writeln(fil,combi); end else continue; closefile(fil); end;
Partager