delay(delayy div 4); 
                             end; 
    x:=x+1; 
   end; 
   end; 
 end; 
GotoXY(80,25); 
ReadLn; 
TextBackGround(Black); 
TextColor(LightGray); 
ClrScr; 
End; 
Procedure change(a1,b1:integer);  {меняет местами два элемента 
массива street} 
 begin 
  if street[a1]=0 then begin street[b1]:=0; street[a1]:=1; end; 
 end; 
Begin 
ClrScr; Randomize; 
Introduction; 
for i:=1 to n do street[i]:=random(2);      {случайное заполнение 
улицы} 
street2:=street; s:=0; left:=0; right:=0; 
write('   '); 
For i:=1 to n do begin 
if street[i]=1 then textcolor(LightRed) else TextColor(yellow); 
write(street2[i],' '); 
end; 
writeln; 
writeln; 
  for i:=1 to n do if street[i]=1 then s:=s+1;{считаем общее число 1} 
  for i:=1 to s do if street[i]=1 then left:=left+1;{определяем к 
какому краю} 
  for i:=n-s+1 to n do if street[i]=1 then 
right:=right+1;{рациональнее } 
  if left>=right then begin i:=0; j:=n+1; a:=1; b:=-1; q:=s-
left;end{премещать} 
                 else begin i:=n+1; j:=0; a:=-1;b:=1;  q:=s-right; 
end;{} 
for f:=1 to q do begin 
repeat i:=i+a; until street[i]=0;{находим крайний нолик} 
repeat j:=j+b; until street[j]=1;{находим крайнюю единичку} 
change(i,j);                     {меняем их местами} 
textcolor(LIghtgreen); 
write(f,') '); 
For k:=1 to n do begin           {выводим полученное на экран} 
if street[k]=1 then textcolor(LightRed) else textcolor(Yellow); 
write(street[k],' '); 
end; 
Writeln; 
end; 
TextColor(LightRed); 
GotoXY(56,24);Write('1');TextColor(Yellow); 
write(' - Семья Паскалёвых '); 
GotoXY(56,25); 
write('0');TextColor(LightRed); 
write(' - Семья Сиплюсплюсовых ');TextColor(LightGray); 
GotoXy(2,25);Write('Press');TextColor(DarkGray); 
Write(' any key');TextColor(LightGray); 
write(' to exit.'); 
i:=1;j:=1;