Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with entrees_sorties; use entrees_sorties;
- procedure tp7_1 is
- NB_ELTS : constant Integer := 100;
- subtype Intervalle is Integer range 1..NB_ELTS;
- type TabEntiers is array(Intervalle) of Integer;
- monTabEntiers : TabEntiers;
- entierCourant : Integer;
- indice : Integer;
- nbEntiers : Integer;
- produitTotal : Integer;
- valMax, idMax : Integer;
- begin
- indice := 1;
- nbEntiers := 0;
- entierCourant := 0;
- put("Entrez les [au plus 100] valeurs a stocker dans le tableau (terminez la saisie par -1)");
- new_line;
- while(entierCourant /= -1 AND nbEntiers < NB_ELTS) loop
- put("Valeur de l'element"&Integer'Image(indice)&" ? ");
- get(entierCourant);
- if(entierCourant /= -1) then
- monTabEntiers(indice) := entierCourant;
- indice := indice+1;
- nbEntiers := nbEntiers+1;
- end if;
- end loop;
- if(nbEntiers > 0) then
- put("Les"&Integer'Image(nbEntiers)&" valeurs contenues dans le tableau sont : ");
- produitTotal := 1;
- valMax := 0;
- for i in 1..nbEntiers loop
- put(monTabEntiers(i), 0);
- produitTotal := produitTotal * monTabEntiers(i);
- if(monTabEntiers(i) > valMax OR i = 1) then
- valMax := monTabEntiers(i);
- idMax := i;
- end if;
- if(i < nbEntiers) then
- put(", ");
- else
- put(".");
- end if;
- end loop;
- new_line;
- put("Le produit des elements est :"&Integer'Image(produitTotal));
- new_line;
- put("La valeur maximale stockee dans le tableau est :"&Integer'Image(valMax));
- new_line;
- put("Elle est situee a la position"&Integer'Image(idMax));
- else
- put("Aucun entier n'a ete saisi.");
- end if;
- end tp7_1;
Advertisement
Add Comment
Please, Sign In to add comment