Var f,h:text; i,maxi:integer; ar:array[1..n] of real; begin ar[6]:=real.MinValue; assign(f,'text.txt'); rewrite(f); for i:=1 to n-1 do begin readln(ar[i]); if ar[i]>ar[6] then begin ar[6]:=ar[i]; maxi:=i; end; end; ar[maxi]:=ar[maxi]/2; writeln('F:'); for i:=1 to n do begin write(f,ar[i],' '); write(ar[i],' '); end; close(f); writeln; i:=0; writeln('H:'); assign(h,'text1.txt'); rewrite(h); while i<n do begin i:=i+2; write(h,ar[i],' '); write(ar[i]:4); end; close(h); end.
Пример ввода: 1 2 3 4 5 Пример вывода: F: 1 2 3 4 2.5 5 H: 2 4 5
const nx = 20; var x: array[1..nx, 1..nx] of integer;z:array[1..nx*2] of integer; i, j, k,n,r,t: integer; begin Writeln('Введите размер матрицы n');Read(n); for i := 1 to n do begin for j := 1 to n do begin Read(k);x[i, j] := k; end;end; Writeln('Исходный массив'); for i := 1 to n do begin for j := 1 to n do begin Write(x[i, j]:4); if x[i, j]>0 then begin t:=t+1; z[t]:=x[i, j];end; end; Writeln; end; Writeln;Writeln('Одномерный массив'); for j := 1 to t do Write(z[j]:4); end.
Const
n=6;
Var
f,h:text;
i,maxi:integer;
ar:array[1..n] of real;
begin
ar[6]:=real.MinValue;
assign(f,'text.txt');
rewrite(f);
for i:=1 to n-1 do
begin
readln(ar[i]);
if ar[i]>ar[6] then
begin
ar[6]:=ar[i];
maxi:=i;
end;
end;
ar[maxi]:=ar[maxi]/2;
writeln('F:');
for i:=1 to n do
begin
write(f,ar[i],' ');
write(ar[i],' ');
end;
close(f);
writeln;
i:=0;
writeln('H:');
assign(h,'text1.txt');
rewrite(h);
while i<n do
begin
i:=i+2;
write(h,ar[i],' ');
write(ar[i]:4);
end;
close(h);
end.
Пример ввода:
1
2
3
4
5
Пример вывода:
F:
1 2 3 4 2.5 5
H:
2 4 5
var x: array[1..nx, 1..nx] of integer;z:array[1..nx*2] of integer;
i, j, k,n,r,t: integer;
begin
Writeln('Введите размер матрицы n');Read(n);
for i := 1 to n do begin
for j := 1 to n do begin
Read(k);x[i, j] := k; end;end;
Writeln('Исходный массив');
for i := 1 to n do begin
for j := 1 to n do begin
Write(x[i, j]:4);
if x[i, j]>0 then begin t:=t+1; z[t]:=x[i, j];end;
end;
Writeln; end;
Writeln;Writeln('Одномерный массив');
for j := 1 to t do
Write(z[j]:4);
end.