procedure aire_perimetre_carre(E cote:reel, S aire:reel, S perimetre:reel) { aire <-- cote * cote perimetre <-- 4 * cote } Algorithme Appel_aire_perimetre { variable c, a, p : reel Afficher("Saisir le coté du carre : ") Saisir(c) aire_perimetre_carre(c, a, p) Afficher("L'aire et le périmètre du carré de coté ", c, " sont ", a, " et ", p, ".\n") } procedure est_impair(E x:entier, S impair: booleen) { Si (x mod 2 = 0) alors { impair <-- FAUX } sinon { impair <-- VRAI } } Algorithme Appel_est_impair { variable n : entier impair : booleen Afficher("Saisir un nombre : ") Saisir(n) est_impair(n, impair) Si (impair) alors Afficher("Le nombre ", n, " est impair.\n") sinon Afficher("Le nombre ", n, " est pair.\n") } procedure ajout_dix(E/S x:entier) { x <-- x + 10 } Algorithme Appel_ajout_dix { variable n : entier Afficher("Saisir un nombre : ") Saisir(n) ajout_dix(n) Afficher("Le nombre est maintenant ", n, ".\n") } Algorithme Appel_ajout_dix_version2 { variable n, n_sauv : entier Afficher("Saisir un nombre : ") Saisir(n) n_sauv <-- n ajout_dix(n) Afficher("Le nombre initial était", n_sauv, "et il vaut maintenant ", n, ".\n") } procedure permutation(E/S A: entier, E/S B: entier) { variable Z : entier Z <-- A A <-- B B <-- Z } Algorithme Appel_permutation { variable n, m : entier Afficher("Saisir deux nombres : ") Saisir(n, m) permutation(n,m) Afficher("Le premier nombre est maintenant ", n, " et le second est ", m,".\n") } procedure tri_croissant(E/S A : entier, E/S B : entier, E/S C : entier) { Si (A > B) alors { permutation(A,B) } Si (B > C) alors { permutation(B,C) } Si (A > B) alors { permutation(A,B) } } Algorithme Appel_tri { variable a,b,c : entier Afficher("Saisir trois entiers : ") Saisir(a,b,c) tri_croissant(a,b,c) Afficher("Le résultat du tri est ",a,"<",b,"<",c,".\n") } procedure division_euclidienne(E A : entier, E B : entier, S quotient : entier, S reste : entier) { quotient <-- A div B reste <-- A mod B } Algorithme Appel_division { variable a,b,q,r : entier Afficher("Saisir deux entiers : ") Saisir(a,b) division_euclidienne(a,b,q,r) Afficher("Le quotient de la division euclidienne de ",a, " par ", b, " est ",q," et le reste est ",r,".\n") } procedure nb_jours_du_mois(E mois : entier, E annee : entier, S nbjours : entier) { Selon(mois) { 1, 3, 5, 7, 8, 10, 12 : nbjours <-- 31 4, 6, 9, 11 : nbjours <-- 30 2 : Si (annee mod 4 = 0) alors nbjours <-- 29 sinon nbjours <-- 28 } } Algorithme Appel_nbjours { variable mois, annee, nbj : entier Afficher("Saisir un mois et une année : ") Saisir(mois, annee) nb_jours_du_mois(mois, annee, nbj) Afficher("Il y a ", nbj, " jours dans le mois ", mois,"/",annee,".\n") }