Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. program laba4;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8. System.SysUtils,Math;
  9.  
  10. const n = 4;
  11. const m = 15;
  12. Type Tmas = array [1..n] of integer;
  13. Type Tmasresult = array [0..m] of integer;
  14.  
  15. var A,B:TMAS;
  16. Aresult,Bresult:Tmasresult;
  17. ResultIndex,Acurrent,Bcurrent,ResultCount,i,j,IncreaseSize:integer;
  18.  
  19.  
  20. begin
  21. A[1]:=1; A[2]:=2; A[3]:=3; A[4]:=5;
  22. B[1]:=1; B[2]:=3; B[3]:=3; B[4]:=5;
  23.  
  24. Resultindex:=1;
  25. ResultCount:=1;
  26. Aresult[0]:=0;
  27. Bresult[0]:=0;
  28. i:=1;
  29.  
  30. while i<n do
  31.  
  32. begin
  33. Aresult[ResultIndex]:=A[i];
  34. Bresult[ResultIndex]:=B[i];
  35. ResultIndex:=ResultIndex+1;
  36. IncreaseSize:=0;
  37. j:=0;
  38. while j<ResultCount do
  39. begin
  40. Acurrent:=A[i]+Aresult[j];
  41. Bcurrent:=B[i]+Bresult[j];
  42.  
  43. Aresult[ResultIndex]:=Acurrent;
  44. Bresult[ResultIndex]:=Bcurrent;
  45.  
  46. ResultIndex:=ResultIndex+1;
  47. IncreaseSize:=IncreaseSize+1;
  48. j:=j+1;
  49. end;
  50. ResultCount:=ResultCount+IncreaseSize+1;
  51.  
  52.  
  53. i:=i+1;
  54.  
  55.  
  56.  
  57. end;
  58.  
  59.  
  60. for i := 1 to m do
  61. Write(Aresult[i], ' ' );
  62. writeln;
  63. for i := 1 to m do
  64. Write(Bresult[i], ' ' );
  65. readln;
  66.  
  67. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement