Home Exercices Chapitre 3 : Les structures itératives Affichage pyramidal d'une chaîne de caractères
Bookmark and Share

Liens sponsorisés

Login Form



Affichage pyramidal d'une chaîne de caractères Print E-mail
Written by Administrator   

Écrire un programme qui affiche une chaîne de caractères de cette manière :

pour ch = "www.algointro.info"

w
ww
www
www.
www.a
www.al
www.alg
www.algo
www.algoi
www.algoin
www.algoint
www.algointr
www.algointro
www.algointro.
www.algointro.i
www.algointro.in
www.algointro.inf
www.algointro.info

Solution en Pascal :

program pyramid;
uses wincrt;
var
  s,ch: string;
  i: integer;

begin
write('Donner une chaine pour un affichage pyramidal : ');
readln(ch);
s:='';
for i:=1 to length(ch) do
           begin
                s:=s+ch[i] ;
                writeln (s);
           end ;
end.

 

 

 

Liens sponsorisés