Binary coding of 0 and 1

merassou Posted messages 2 Status Member -  
 Anonymous user -
```pascal
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
begin
repeat
writeln('donner l''élément', 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);

l := 1;
j := 1;
T2[i] := '';

while (j <= 8) do
begin
element := T1[i][j];
nbre := 1;
while (j < 8) and (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];
end
else
begin
T2[i] := T2[i] + T1[i][j];
end;
j := j + 1;
end;
end;

for i := 1 to n do
writeln (T2[i]);
end.
```

2 answers

  1. Anonymous user
     
    Hello, thank you, or please are essential to any request as these words mark basic politeness and show the respect that every requester should have towards the volunteers who run this forum.

    So please rephrase your question correctly.

    --
    When I was little, the Dead Sea was just sick.
    George Burns
    0
    1. merassou Posted messages 2 Status Member
       
      Thank you for your response.
      If you scroll down a little in my question, you will find the word please in English and what it means is thank you ;)
      0