Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program one;
- var
- a,b,i,j:integer;
- l,e:integer;
- h:array[1..10] of integer;
- begin
- //readln(a,b);//вводим интервал
- l := 10;
- a := 3;
- b := 6;
- {заполняем и выводим исходный}
- for i:=1 to 10 do
- begin
- h[i]:=i;
- write(h[i], ' ');
- end;
- writeln;
- {Тут будем пытаться "сжать" массив}
- {сначала обнулим числа в интервали от [a,b]}
- for i:=1 to l do
- begin
- if ((a<=h[i]) and (h[i]<=b)) then
- begin
- h[i]:=0;
- end;
- end;
- {двигаем}
- for i := 1 to l do
- begin
- if h[i] = 0 then
- begin
- j := i;
- while (h[j] = 0) and (j < l) do
- begin
- j := j + 1;
- end;
- if j <= l then
- begin
- h[i] := h[j];
- h[j] := 0;
- end;
- end;
- end;
- {выводим результат}
- for i:=1 to l do
- write(h[i], ' ');
- writeln;
- end.
Add Comment
Please, Sign In to add comment