Ответы и объяснения

2013-05-22T20:45:39+04:00

 

1)

var

a:array [1..10] of integer;

min,max,buf,i,g,l:integer;

begin

randomize;

for i:=1 to 10 do begin

a[i]:=random(16)+5;

write (a[i],' ');

end;

writeln;

max:=a[1];

min:=a[1];

for i:=2 to 10 do

if a[i]>max then

begin

max:=a[i];

g:=i;

end else

if a[i]<min then

begin

min:=a[i];

l:=i;

end;

buf:=a[g];

a[g]:=a[min];

a[l]:=buf;

for i:=1 to 10 do write (a[i],' ');

writeln; 

readln;

end.

 

2)

const

n=10;

var

a:array [1..n] of integer;

j,i,max,k:integer;

begin

randomize;

for i:=1 to n do begin

a[i]:=random(11)+10;

write (a[i],' ');

end;

writeln;

max:=1; 

k:=1; 

for i:=1 to n-1 do begin

for j:=i+1 to n do

if a[i]=a[j] then k:=k+1;

if k>max then max:=k;

k:=1; 

end;

writeln (max);

readln;

end.