Bonjour à tous,
voila l'énoncé :
J'ai pensé à ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part Recherchez des entiers n'apparaissant qu'une fois dans un tableau non-trié et non croissant et les récpuérer .
seulement le problème est que j'obitens un value outOfrange a cause du i+1 quand celui-ci vaut 5 et je ne vois pas comment parcourir entierement le tableau sans utiliser cela :s cela doit etre tout bete mais bon d'avance 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 program trirepetition; var repet,i,l,current : integer; tab : array[1..5] of integer; tabNoRepet : array[1..5] of integer; begin i := 1; l := 1; repet := 0; while(i<=5) do begin current := tab[l]; if(current<>tab[i+1]) then begin i := i + 1; repet := 0; if(i=6) then begin tabNoRepet[l] := tab[i]; l := l + 1; end; end; if(current=tab[i+1]) then begin repet := 1; i := i + 1; l := l + 1; end; end; end.![]()
Partager