Guest User

Untitled

a guest
Jul 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.78 KB | None | 0 0
  1. var
  2.   a:array[1..100] of Integer;
  3.   i,n:Byte;
  4.   x,y:Integer;
  5.   res:String;
  6. begin
  7.   assign(input,'input.txt');
  8.   reset(input);
  9.   while not eof(input) do
  10.     begin
  11.       inc(n);
  12.       read(a[n])
  13.     end;
  14.   close(input);
  15.   for i:=1 to n do
  16.     case a[i] of
  17.       1: inc(y);
  18.       2: inc(x);
  19.       3: dec(y);
  20.       4: dec(x)
  21.     end;
  22.   if x > 0 then
  23.     for i:=1 to x do
  24.       res:=res+'2 '
  25.   else
  26.     if x < 0 then
  27.       for i:=1 to abs(x) do
  28.         res:=res+'4 ';
  29.   if y > 0 then
  30.     for i:=1 to y do
  31.       res:=res+'1 '
  32.   else
  33.     if y < 0 then
  34.       for i:=1 to abs(y) do
  35.         res:=res+'3 ';
  36.   delete(res,length(res),1); { Should delete last space for beauty :) }
  37.   assign(output,'output.txt');
  38.   rewrite(output);
  39.   writeln(res);
  40.   close(output)
  41. end.
Add Comment
Please, Sign In to add comment