• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled klasscho  Oct 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Program Project5;
2.
3. {\$APPTYPE CONSOLE}
4.
5. uses
6.    sysUtils;
7. const
8.    MaxNumb = 1073741823;
9.    MinNumb = 0;
10. var
11.    a, b, aNew, bNew: array of integer ;
12.    n, i, maxsum, maxind: integer;
13.    IsCorrect: boolean;
14. begin
15.    n := 0;
16.    writeln ('This program displays the numbers of the array elements whose total is the maximum');
17.    repeat
18.       try
19.          writeln('Enter a length of array [1..20] ');
21.          if ((n > 1) and (n < 20)) then
22.             IsCorrect := True
23.          else
24.              writeln('Enter a value between [1..20]');
25.       except
26.          IsCorrect := False;
27.          writeln ('Enter a number!');
28.       end;
29.    until IsCorrect;
30.    setLength(a, n);
31.    setLength(b, n);
32.    setLength(aNew, n);
33.    writeln('Enter the array elements "a": ');
34.    for i := 0 to n - 1 do
35.    begin
36.       repeat
37.          try
38.             write('a[',i,']= ');
40.             if ((a[i] > MinNumb) or (a[i] < (MaxNumb))) then
41.                IsCorrect := True
42.             else
43.                writeln('Enter a sequence item. He is must be more ', MinNumb,' but less than ',MaxNumb);
44.          except
45.             IsCorrect := False;
46.             writeln ('Enter a number!');
47.           end;
48.       until IsCorrect;
49.    end;
50.    writeln('Enter the array elements "b": ');
51.    for i := 0 to n - 1 do
52.    begin
53.       repeat
54.          try
55.             write('b[',i,']= ');
57.             if ((b[i] > MinNumb) or (b[i] < (MaxNumb))) then
58.                IsCorrect := True
59.             else
60.                writeln('Enter a sequence item. He is must be more ', MinNumb,' but less than ',MaxNumb);
61.          except
62.             IsCorrect := False;
63.             writeln ('Enter a number!');
64.           end;
65.       until IsCorrect;
66.    end;
67.    maxsum := a + b;
68.    maxind := 0;
69.    for i := 0 to n - 1 do
70.    begin
71.       if a[i] + b[i] > maxsum then
72.       begin
73.          maxsum := a[i] + b[i];
74.          maxind := i;
75.       end;
76.    end;
77.    writeln ('At this value ', maxind,' the pair is the largest');