programme MIN-MAX
aide scolaire :: informatique :: programmation pascal :: les structures conditionnelles :: exercices
Page 1 sur 1
programme MIN-MAX
ENONCE
Ecrire une analyse, un algorithme et un programme pascal permettant d’afficher le maximum et le minimum de deux entiers donnés.
ANALYSE
Résultat=Ecrire (min, max)
Min, max=[ ]
SI x<y
ALORS
Min<- x
max<- y
SINON
Min<- y
max<- x
FIN SI
N=donnée
Fin Min_Max
ALGORITHME
1) Début Min_Max
2) Ecrire (« donner deux entiers »)
Lire (X,Y)
3) SI X<Y
ALORS Min<- x
max<- y
SINON
Min<- y
max<- x
FIN SI
4)Ecrire ("le minimum de",X, "et",Y, " est",Min, "et leur maximum est : ",max)
5) Fin Min_Max
PASCAL
Program Min_Max ;
uses wincrt;
Var X,Y,Min,Max:integer ;
Begin
Writeln ('donner deux entiers');
Read (X,Y);
IF X>Y THEN Begin Max:=X ;
Min:=Y;
End
ELSE Begin Max:=Y ;
Min:=X;
End;
Write ('le maximum est:', Max, ' et le minimum est : ',Min) ;
End.
Ecrire une analyse, un algorithme et un programme pascal permettant d’afficher le maximum et le minimum de deux entiers donnés.
ANALYSE
Résultat=Ecrire (min, max)
Min, max=[ ]
SI x<y
ALORS
Min<- x
max<- y
SINON
Min<- y
max<- x
FIN SI
N=donnée
Fin Min_Max
ALGORITHME
1) Début Min_Max
2) Ecrire (« donner deux entiers »)
Lire (X,Y)
3) SI X<Y
ALORS Min<- x
max<- y
SINON
Min<- y
max<- x
FIN SI
4)Ecrire ("le minimum de",X, "et",Y, " est",Min, "et leur maximum est : ",max)
5) Fin Min_Max
PASCAL
Program Min_Max ;
uses wincrt;
Var X,Y,Min,Max:integer ;
Begin
Writeln ('donner deux entiers');
Read (X,Y);
IF X>Y THEN Begin Max:=X ;
Min:=Y;
End
ELSE Begin Max:=Y ;
Min:=X;
End;
Write ('le maximum est:', Max, ' et le minimum est : ',Min) ;
End.
aide scolaire :: informatique :: programmation pascal :: les structures conditionnelles :: exercices
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum