Var i,su1,su2:integer; a:array[1..10] of integer; input,output:text; begin assign(input,'input.txt'); assign(output,'output.txt'); reset(input); rewrite(output); for i:=1 to 10 do read(input,a[i]); for i:=1 to 10 do begin if a[i]>0 then inc(su1,a[i]) else inc(su2,a[i]); end; writeln(output,'Сумма положительных:',su1); write(output,'Сумма отрицательных:',su2); close(input); close(output); end.
Cортировка была реализована методом пузырька var i, n, j, b, k: integer; M, A: array [1..20] of integer; begin n := 1; for i := 1 to 20 do begin read (M[i]); if M[i] > 5 then begin A[n] := M[i]; inc(n); end; end; for j := 1 to n - 1 do for i := 1 to n - j do if A[i] > A[i + 1] then begin b := A[i]; A[i] := A[i + 1]; A[i + 1] := b; end; write('Начальный массив: '); for i := 1 to 20 do write (M[i], ' '); writeln; write('Новый массив: '); for i := 1 to n do write (A[i], ' '); end.
i,su1,su2:integer;
a:array[1..10] of integer;
input,output:text;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
for i:=1 to 10 do
read(input,a[i]);
for i:=1 to 10 do
begin
if a[i]>0
then
inc(su1,a[i])
else
inc(su2,a[i]);
end;
writeln(output,'Сумма положительных:',su1);
write(output,'Сумма отрицательных:',su2);
close(input);
close(output);
end.
var i, n, j, b, k: integer;
M, A: array [1..20] of integer;
begin
n := 1;
for i := 1 to 20 do
begin
read (M[i]);
if M[i] > 5 then
begin
A[n] := M[i];
inc(n);
end;
end;
for j := 1 to n - 1 do
for i := 1 to n - j do
if A[i] > A[i + 1] then
begin
b := A[i];
A[i] := A[i + 1];
A[i + 1] := b;
end;
write('Начальный массив: ');
for i := 1 to 20 do
write (M[i], ' ');
writeln;
write('Новый массив: ');
for i := 1 to n do
write (A[i], ' ');
end.