Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses
- System.SysUtils;
- var
- arr: array of integer;
- I,J, N, sum: integer;
- begin
- Write('N = ');
- ReadLn(N);
- SetLength(arr, N);
- {Заполнение массива числами от 0 до N (не включая)}
- for I := 0 to N - 1 do
- arr[i]:= i;
- WriteLn('1st task');
- for I := 0 to N - 1 do
- begin
- if(arr[I] mod 2 = 0) then WriteLn(arr[I]);
- end;
- WriteLn('2nd task');
- for I:= N - 1 downto 0 do
- begin
- if(arr[I] mod 2 <> 0) then WriteLn(arr[I]);
- end;
- WriteLn('3rd task');
- for I := 0 to N - 1 do
- begin
- if(arr[I] mod 2 = 0) then
- begin
- WriteLn(arr[I]);
- end;
- if (I = N - 1) then
- begin
- for J := N - 1 downto 0 do
- begin
- if(arr[J] mod 2 <> 0) then WriteLn(arr[J]);
- end;
- end;
- end;
- WriteLn('4th task');
- sum:=0;
- j:=0;
- for I := 0 to N - 1 do
- begin
- if(arr[I] mod 3 = 0) then
- begin
- WriteLn(arr[I]);
- sum:= sum + arr[i];
- j:= j + 1;
- end;
- end;
- WriteLn(sum, ' - Sum');
- WriteLn(j, ' - Count');
- WriteLn('5th task');
- sum:=0;
- j:=0;
- for I := 0 to N - 1 do
- begin
- j:= j + 1;
- sum:= sum + arr[i];
- end;
- WriteLn('Average - ' , sum / j);
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement