1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Program Exo3 ;
USES crt;
Var T : array [1..30] of char;
I, N , Occ: Integer ;
Possible : Boolean ;
Begin
clrscr;
Write ('Entrez le nombre d''éléments du tableau (<=30) ') ;
readln(N) ;
Possible :=False ;
Occ :=0;
For i :=1 To N Do
Begin
Write ('Donnez la valeur de l''élément ',i,' du tableau ') ;
Readln (T[i]) ;
If T[i]='a' then Possible :=True;
If (T[i]='b') and (Possible=True) then begin
Occ :=Occ+1;
Possible:=False;
end
else If ((T[i]<>'b') and (T[i]<>'a')) and (Possible=True) then
Possible:=false;
end;
write('Le taux d''apparition de la succession des 2 caractères ''a'' et ''b'' est égal à ',Occ) ;
readln;
end. |
Partager