Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- a:array[1..100] of Integer;
- i,n:Byte;
- x,y:Integer;
- res:String;
- begin
- assign(input,'input.txt');
- reset(input);
- while not eof(input) do
- begin
- inc(n);
- read(a[n])
- end;
- close(input);
- for i:=1 to n do
- case a[i] of
- 1: inc(y);
- 2: inc(x);
- 3: dec(y);
- 4: dec(x)
- end;
- if x > 0 then
- for i:=1 to x do
- res:=res+'2 '
- else
- if x < 0 then
- for i:=1 to abs(x) do
- res:=res+'4 ';
- if y > 0 then
- for i:=1 to y do
- res:=res+'1 '
- else
- if y < 0 then
- for i:=1 to abs(y) do
- res:=res+'3 ';
- delete(res,length(res),1); { Should delete last space for beauty :) }
- assign(output,'output.txt');
- rewrite(output);
- writeln(res);
- close(output)
- end.
Add Comment
Please, Sign In to add comment