Bonjour,
je voudrais généré un nombre dans un tableau et il doit apparaitre une seule fois dans le tableau.
mon problème présentement est qu'il se retrouve plusieurs fois dans chaque ligne.
Merci
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
38 program Hasard; type tab1=array [1..10] of integer ; tab2=array [1..10] of integer; const j=10; var c,d,i:integer; a:tab1; b:tab2; begin writeln('Appuyer sur <enter> pour afficher '); write('les resultats du tirage au sort.'); readln; randomize; for c:=1 to 10 do begin a[c]:=random(j); if a[c]=a[c] then a[c]:=random(j)-a[c]; //élimination du nombre (mais je crois qu'il le soustrait) write(a[c],' '); end; writeln('mon equipe');; for d:=1 to 10 do begin b[c]:=random(j); if b[d]=b[d] then b[d]:=random(j)-b[d]; //élimination du nombre (mais je crois qu'il le soustrait) write(b[d],' '); end; writeln('Adversaire'); write('Merci !'); readln; end.
Partager