Bonjour

Je voudrais transformer mon code pour le rendre plus propre, et je pense que je dois faire une truc recursif. Mais voilà, j'y arrive pas. Je sais pas comment m'y prendre.
J'ai fait mon code pour cas avec nb = 8 (et donc je me tape du i, j, k, l, m, o, p) mais je voudrais pouvoir le faire fonctionner avec nb = 10 ou nb = n'importe quel chiffre paire.
Donc ma question, c'est comment on s'y prend pour faire du recursif à part appeller LA fonction dans LA fonction.

Merci d'avance

Voilà mon code

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
 
for i:=0 to nb-1 do begin
for j:=0 to nb-1 do begin
for k:=0 to nb-1 do begin
for l:=0 to nb-1 do begin
for m:=0 to nb-1 do begin
for n:=0 to nb-1 do begin
for o:=0 to nb-1 do begin
for p:=0 to nb-1 do begin
if ( ((i <> j)and(i <> k)and(i <> l)and(i <> m)and(i <> n)and(i <> o)and(i <> p))
and((j <> k)and(j <> l)and(j <> m)and(j <> n)and(j <> o)and(j <> p))
and((k <> l)and(k <> m)and(k <> n)and(k <> o)and(k <> p))
and((l <> m)and(l <> n)and(l <> o)and(l <> p))
and((m <> n)and(m <> o)and(m <> p))
and((n <> o)and(n <> p))
and((o <> p))
) then begin
inc(a);
setlength(tab, a);
tab[a-1] := tab_1[i] +tab_2[i,j] + tab_1[j];
tab[a-1] := tab[a-1] +tab_1[k] + tab_2[k,l] + tab_1[l];
tab[a-1] := tab[a-1] +tab_1[m] + tab_2[m,n] + tab_1[n];
tab[a-1] := tab[a-1] +tab_1[o] + tab_2[o,p] + tab_1[p];
end;
end;
end;
end;
end;
end;
end;
end;
end;