Dénombrement avec pascal

Fermé
ghost1 Messages postés 38 Date d'inscription mardi 24 juin 2008 Statut Membre Dernière intervention 9 avril 2009 - 9 avril 2009 à 15:58
Bonjour,
en utilisant TPW 1.5:
j'ai un problème avec mon programme lors de son exécution. La compilation est exacte. impossible d'effectuer les opérations d'arrangement et le combinaison.Pouver vous m'aidez?merci d'avance.
C'est le code :

program denombrement;
uses wincrt;
var
a,n,p,i,factn,factp,factnp,np : integer;
begin
writeln('1.factorl 2.arrangemt 3.combinais');
read(a);
if a=2 then
begin
write('écrire n');
read(n);
write('ecrire p');
read(p);
np:= n-p;
factn:= 1;
factp:= 1;
for i:=2 to n do
factn:= factn *i;
for i:=2 to p do
factp:= factp*i;
for i:=2 to np do
factnp:= factnp*i;
write('lavaleur est',factn/factnp);
end
else if a=1 then
begin
write('écrire l''enti');
read(n);
factn:= 1;
for i:= 2 to n do
factn:= factn*i;
write('le factoriel de cet entier est',factn)
end
else if a=3 then
begin
write('écrire n');
read(n);
write('ecrire p');
read(p);
np:= n-p;
factn:= 1;
factp:= 1;
for i:=2 to n do
factn:= factn *i;
for i:=2 to p do
factp:= factp*i;
for i:=2 to np do
factnp:= factnp*i;
write('lavaleur est',factn/(factnp*factp));
end;
end.
A voir également: