Максимальный элемент массивов A и B с тем же индексом
Код:
var
a:array[1..100] of integer;
b:array[1..100] of integer;
c:array[1..100] of integer;
i,n: integer;
begin
write ('Введите число n ');
readln(n);
randomize;
for i:=1 to n do
begin
a[i]:= random(10);
write(a[i],' ');
end;
writeln;
for i:=1 to n do
begin
b[i]:= random(10);
write(b[i],' ');
end;
writeln;
for i:=1 to n do
if a[i]>b[i] then write(a[i],' ') else write(b[i],' ');
readln;
end.
a:array[1..100] of integer;
b:array[1..100] of integer;
c:array[1..100] of integer;
i,n: integer;
begin
write ('Введите число n ');
readln(n);
randomize;
for i:=1 to n do
begin
a[i]:= random(10);
write(a[i],' ');
end;
writeln;
for i:=1 to n do
begin
b[i]:= random(10);
write(b[i],' ');
end;
writeln;
for i:=1 to n do
if a[i]>b[i] then write(a[i],' ') else write(b[i],' ');
readln;
end.
Код:
program Project1;
{$APPTYPE CONSOLE}
var
a:array[1..100] of integer;
b:array[1..100] of integer;
c:array[1..100] of integer;
i,N: integer;
begin
write ('N (1..100): ');
readln(N);
randomize;
for i:=1 to N do
begin
a[i]:= random(10);
b[i]:= random(10);
if a[i]>b[i] then c[i]:=a[i] else c[i]:=b[i];
end;
write('a[]: ');
for i:=1 to n do write(a[i], '; ');
writeln;
write('b[]: ');
for i:=1 to n do write(b[i], '; ');
writeln;
write('c[]: ');
for i:=1 to n do write(c[i], '; ');
readln;
end.
{$APPTYPE CONSOLE}
var
a:array[1..100] of integer;
b:array[1..100] of integer;
c:array[1..100] of integer;
i,N: integer;
begin
write ('N (1..100): ');
readln(N);
randomize;
for i:=1 to N do
begin
a[i]:= random(10);
b[i]:= random(10);
if a[i]>b[i] then c[i]:=a[i] else c[i]:=b[i];
end;
write('a[]: ');
for i:=1 to n do write(a[i], '; ');
writeln;
write('b[]: ');
for i:=1 to n do write(b[i], '; ');
writeln;
write('c[]: ');
for i:=1 to n do write(c[i], '; ');
readln;
end.