A voir également:
- Tous les code possible de 0 à 9 (4 chiffres ) liste
- Nombre de combinaison possible avec 10 chiffres - Meilleures réponses
- Tous les code possible de 1 à 9 (4 chiffres ) - Meilleures réponses
- Tous les code possible de 0 à 9 (4 chiffres ) - Forum Jeux vidéo
- Toutes les combinaisons à 4 chiffres de 0000 a 9999 - Forum Programmation
- +33 4 24 47 31 44 ✓ - Forum Mobile
- Code ascii - Guide
- Liste déroulante excel - Guide
6 réponses
voici un programme pascal qui affiche toutes les combinaisons possibles des caractères numériques (chiffres) ou alphabétiques dans une chaîne ch, sachant que le nombre de combinaisons est égale au factoriel du nombre total des chiffres , exemple pour ch = 123 il existe 3! combinaisons = 6 combinaison= 6 permutations: pour le nombre 123
le programme affiche 213-231-132-312-321-123
Program combinaison;
Uses WinCrt;
Var ch:string;
Procedure Remplir (Var ch:string);
begin
writeln('donner le nombre');
Readln(ch);
End;
procedure permut(var x,y:char);
var aux:char;
begin
aux:=x;
x:=y;
y:=aux
end;
function fact(x:integer):integer;
var f,i:integer;
begin
f:=1;
for i:= 1 to x do
begin
f:=f*i ;
end;
fact:=f;
end;
procedure affichecomb(ch:string);
var i,n,np:integer;
begin
n:=length(ch);
np:=0;
repeat
for i:= 1 to n-1 do
begin
permut(ch[i],ch[i+1]);
np:=np+1;
write(ch,'-');
end;
permut(ch[1],ch[n]);
write(ch,'-');
np:=np+1;
until np =fact(length(ch));
end;
begin
remplir(ch);
writeln;
affichecomb(ch);
end.
le programme affiche 213-231-132-312-321-123
Program combinaison;
Uses WinCrt;
Var ch:string;
Procedure Remplir (Var ch:string);
begin
writeln('donner le nombre');
Readln(ch);
End;
procedure permut(var x,y:char);
var aux:char;
begin
aux:=x;
x:=y;
y:=aux
end;
function fact(x:integer):integer;
var f,i:integer;
begin
f:=1;
for i:= 1 to x do
begin
f:=f*i ;
end;
fact:=f;
end;
procedure affichecomb(ch:string);
var i,n,np:integer;
begin
n:=length(ch);
np:=0;
repeat
for i:= 1 to n-1 do
begin
permut(ch[i],ch[i+1]);
np:=np+1;
write(ch,'-');
end;
permut(ch[1],ch[n]);
write(ch,'-');
np:=np+1;
until np =fact(length(ch));
end;
begin
remplir(ch);
writeln;
affichecomb(ch);
end.