6 réponses
Here is the translation:
```html
Here is a Pascal program that displays all possible combinations of numeric (digit) or alphabetic characters in a string ch, knowing that the number of combinations is equal to the factorial of the total number of digits. For example, for ch = 123, there are 3! combinations = 6 permutations: for the number 123
the program displays 213-231-132-312-321-123
Program combinaison;
Uses WinCrt;
Var ch:string;
Procedure Remplir (Var ch:string);
begin
writeln('enter the number');
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. ```
the program displays 213-231-132-312-321-123
Program combinaison;
Uses WinCrt;
Var ch:string;
Procedure Remplir (Var ch:string);
begin
writeln('enter the number');
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. ```