Arfizato

skon

Jun 18th, 2020
1,471
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Program deca ;
  2. Uses Wincrt ;
  3. Type
  4.   tab = Array [1..50] Of Byte ;
  5. Var
  6.   t,t2: tab;
  7.   n,k: Integer;
  8.  
  9. Procedure remp_tab (Var t:tab ; n:Integer);
  10. Var
  11.   i: Integer;
  12. Begin
  13.   For i:=1 To n Do
  14.         begin
  15.             write('T[',i,']= ');
  16.     Readln(t[i]);
  17.       end;
  18. End;
  19.  
  20. Procedure saisi_n(Var n:Integer);
  21. Begin
  22.   Repeat
  23.     Write('N= ');
  24.     Readln(n);
  25.   Until (n>2) And (n<=50);
  26. End ;
  27.  
  28. Procedure saisi_k(Var k :Integer;n:Integer);
  29. Begin
  30.   Repeat
  31.     Write('k= ');
  32.     Readln(k);
  33.   Until (k>=1 ) And (k<n);
  34. End;
  35. Procedure decaler (Var t,t2:tab;n,k:Integer);
  36. Var
  37.   i,x: Integer;
  38.   y: Byte;
  39. Begin
  40.   For i:=1 To n Do
  41.     begin
  42.     x := i+k ;
  43.   If (x>n) Then
  44.     x := x-n;
  45.   t2[x] := t[i];
  46.     end;
  47. End;
  48.  
  49. {
  50. Procedure init(Var t2:tab;n:Integer);
  51. Var
  52.   i: Integer;
  53. Begin
  54.   For i:=1 To n Do
  55.     t[i] := 0;
  56. End;
  57. }
  58.  
  59. Procedure aff(t2:tab;n:Integer);
  60. Var
  61.   i: Integer;
  62. Begin
  63.   For i:=1 To n Do
  64.     Write(t2[i]:4);
  65.     writeln;
  66. End;
  67. Begin
  68.   saisi_n(n) ;
  69.   saisi_k(k,n);
  70.   remp_tab(t,n) ;
  71.     aff(t,n);
  72. {  init(t2,n) ;}
  73.   decaler(t,t2,n,k) ;
  74.   aff(t2,n);
  75. End.
RAW Paste Data