1. var a: array[1..10] of integer; i, kol: Integer; Begin for i := 1 to 10 do read(a[i]); kol := 0; for i := 1 to 10 do if a[i] mod 2=0 then begin kol := kol + 1; write(a[i],' '); end; writeln; writeln(kol); End. 2. var a: array[1..10] of integer; i, kol: Integer; Begin for i := 1 to 10 do read(a[i]); kol := 0; for i := 1 to 10 do if a[i] > 9 then begin kol := kol + 1; write(a[i],' '); end; writeln; writeln(kol); End. 3. var a: array[1..10] of integer; i: Integer; Begin for i := 1 to 10 do read(a[i]); for i := 1 to 10 do if a[i] mod 2=0 then write(a[i],' '); for i := 1 to 10 do if a[i] mod 2=1 then write(a[i],' '); End. 4. var a: array[1..10] of integer; i, r: Integer; Begin for i := 1 to 10 do read(a[i]); i := 1; while i < 10 do if a[i+1] < a[i] then begin r := a[i+1]; a[i+1] := a[i]; a[i] := r; i := 1; end else i := i + 1; for i := 1 to 10 do if a[i] mod 2=0 then write(a[i],' '); for i := 1 to 10 do if a[i] mod 2=1 then write(a[i],' '); End. 5. var a: array[1..10] of integer; i, kol: Integer; Begin for i := 1 to 10 do read(a[i]); for i := 1 to 10 do if a[i] mod 10 = 5 then kol := kol + 1; writeln(kol); End.
function gcd(a,b:integer):integer;
// Нахождение НОД
begin
while b<>0 do
begin
a:=a mod b;
var i:=b; b:=a; a:=i
end;
Result:=a
end;
procedure Shorter(var a,b:integer);
// "сокращатель" дроби
begin
var k:=gcd(a,b);
a:=a div k;
b:=b div k
end;
begin
var a,b:integer;
Writeln('Введите числитель и знаменатель дроби: ');
Read(a,b);
Write(a,'/',b,'='); Shorter(a,b); Writeln(a,'/',b)
end.
Тестовое решение:
Введите числитель и знаменатель дроби:
25 15
25/15=5/3
i, kol: Integer;
Begin
for i := 1 to 10 do read(a[i]);
kol := 0;
for i := 1 to 10 do
if a[i] mod 2=0 then
begin
kol := kol + 1;
write(a[i],' ');
end;
writeln;
writeln(kol);
End.
2. var a: array[1..10] of integer;
i, kol: Integer;
Begin
for i := 1 to 10 do read(a[i]);
kol := 0;
for i := 1 to 10 do
if a[i] > 9 then
begin
kol := kol + 1;
write(a[i],' ');
end;
writeln;
writeln(kol);
End.
3. var a: array[1..10] of integer;
i: Integer;
Begin
for i := 1 to 10 do read(a[i]);
for i := 1 to 10 do
if a[i] mod 2=0 then write(a[i],' ');
for i := 1 to 10 do
if a[i] mod 2=1 then write(a[i],' ');
End.
4. var a: array[1..10] of integer;
i, r: Integer;
Begin
for i := 1 to 10 do read(a[i]);
i := 1;
while i < 10 do
if a[i+1] < a[i] then begin
r := a[i+1];
a[i+1] := a[i];
a[i] := r;
i := 1;
end else i := i + 1;
for i := 1 to 10 do
if a[i] mod 2=0 then write(a[i],' ');
for i := 1 to 10 do
if a[i] mod 2=1 then write(a[i],' ');
End.
5. var a: array[1..10] of integer;
i, kol: Integer;
Begin
for i := 1 to 10 do read(a[i]);
for i := 1 to 10 do
if a[i] mod 10 = 5 then kol := kol + 1;
writeln(kol);
End.