Program prog1;
Uses crt;
var a: array [1..50] of integer;
k, i: integer;
begin
clrscr; randomize;
for i:=1 to 50 do
begin
a[i]:= random(41);
write(a[i],' ');
if a[i]=23 then inc(k);
end;
writeln;writeln; writeln('k = ',k);
end.
Program prog2;
Uses crt;
var a: array [1..50] of integer;
i: integer;
begin
clrscr; randomize;
for i:=1 to 50 do
begin
a[i]:= random(41);
write(a[i],' ');
if (a[i] mod 5) =0 then a[i]:=-1;
end;
writeln;writeln;
for i:=1 to 50 do
write(a[i],' ');
end.
Program prog3;
Uses crt;
var a: array [1..10] of integer;
tmp, i: integer;
begin
clrscr; randomize;
for i:=1 to 10 do
begin
a[i]:= random(41);
write(a[i],' ');
end;
tmp:=a[2];
a[2]:=a[9];
a[9]:=tmp;
writeln;writeln;
for i:=1 to 10 do
write(a[i],' ');
end.
Program prog4;
Uses crt;
var a: array [1..100] of integer;
n, i,k: integer;
begin
clrscr; randomize;
write('N = ');
readln(n);
for i:=1 to n do
begin
a[i]:= random(41);
write(a[i],' ');
end;
writeln;writeln;
for i:=1 to n-1 do
if ((a[i] mod 10)=2)and((a[i+1] mod 10)=2) then inc(k);
writeln('k = ', k);
end.