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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| program binaire;
uses WinCrt;
type
tab= array[1..8] of string;
var
i,n,j,nbre,l: integer;
T1,T2:tab;
bb:boolean;
res,chnbre:string;
element:char;
begin
repeat
writeln ('n=');
readln (n);
until n in [2..8];
for i:=1 to n do
repeat
writeln('donner l"element',i);
readln (T1[i]);
j:=0; bb:=true;
repeat
j:=j+1;
if not( T1[i][j] in ['0'..'1']) then
bb:=false;
until (length (T1[i])=8) or (bb=false);
until (length (T1[i])=8) and (bb);
for i:=1 to n do
begin
nbre:=1;l:=1;
repeat
element:=T1[i][j]; nbre:=1;
while (T1[i][j+1]=element) do
begin
j:=j+1;
nbre:=nbre+1
end;
if (nbre>1) then
begin
str(nbre,chnbre);
T2[i]:=T2[i]+chnbre+T1[i][j-1];
end
else
begin T2[i]:=T2[i]+T1[i][j]; j:j+1; end; l:=j+1;
until (l>8);
end;
for i:=1 to n do
writeln (T2[i]);
end. |
Partager