SHARE
TWEET

Untitled

a guest Aug 12th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program sdv;
  2. uses crt;
  3. const n=4;
  4. type m=array[1..n] of integer;
  5. var i,j,r,k:integer;
  6.     a,a1:m;
  7.  
  8. procedure sdvigm(var a1:m;k:integer);
  9.  begin
  10.   for i:= 1 to abs(k) do
  11.     begin
  12.      for j:= 1 to n do
  13.       if (j=1) then r:=a[j]
  14.       else a[j-1]:=a[j];
  15.       a[n]:=r;
  16.     end;
  17.     for i:= 1 to n do write(a[i]:2);
  18.   end;
  19.  
  20. procedure sdvigp(var a:m;k:integer);
  21.  begin
  22.   for i:= 1 to k do
  23.     begin
  24.      for j:= n downto 1 do
  25.       if (j=n) then r:=a[n]
  26.       else a[j+1]:=a[j];
  27.       a[1]:=r;
  28.     end;
  29.     for i:= 1 to n do write(a[i]:2);
  30.   end;
  31.  
  32. begin
  33.  clrscr;
  34.  randomize;
  35.   for i:= 1 to n do
  36.    begin
  37.     a[i]:=1+random(9);
  38.     write(a[i]:2);
  39.    end;
  40.    a1:=a;
  41.    writeln;
  42.    repeat
  43.    write('C KaKogo el. dvigat: ');
  44.   read(k);
  45.    until k<n;
  46.     if (k<0) then sdvigm(a1,k)
  47.     else sdvigp(a,k);
  48.   readkey;
  49.  end.
RAW Paste Data
Top