Программа:
Python:
arr = []
n = int(input('Количество учеников: '))
countMan, countWomen, sumMan, sumWomen = 0, 0, 0, 0
print(f'Введите рост {n} учеников')
for i in range(n):
height = int(input())
if abs(height) > 300 or abs(height) < 30:
print('Введите правильные данные')
else:
if height < 0:
countMan += 1
sumMan += height
countWomen += 1
sumWomen += height
print(abs(int(sumMan/countMan)), int(sumWomen/countWomen))
var slova, bukvy, slovo : string;
i, b, k, c, j, l, kolvo, dlina1, dlina2 : integer;
a : array[1..50] of string;
begin
Writeln('Введите слова');
Readln(slova);
Writeln('Введите буквы');
Readln(bukvy);
dlina1 := length(slova);
dlina2 := length(bukvy);
k := 1;
for i := 1 to dlina1 do
if slova[i] = ' ' then
k := k + 1;
writeln(k);
b := 1;
i := 1;
while i <= length(slova) do
if (slova[i] <> ' ') and (i <> length(slova)) then
slovo := slovo + slova[i]
else
a[b] := slovo;
slovo := '';
b := b + 1;
end;
i := i + 1;
a[k] := a[k] + slova[length(slova)];
b := 0;
l := 0;
for i := 1 to 50 do
if a[i] <> '' then
slovo := a[i];
for k := 1 to length(slovo) do
for c := 1 to length(bukvy) do
if slovo[k] = bukvy[c] then
j := j + 1;
if j = length(slovo) then
writeln(slovo);
l := l + 1;
j := 0;
if l = 0 then
writeln('NO');
end.
Объяснение:
Программа:
Python:
arr = []
n = int(input('Количество учеников: '))
countMan, countWomen, sumMan, sumWomen = 0, 0, 0, 0
print(f'Введите рост {n} учеников')
for i in range(n):
height = int(input())
if abs(height) > 300 or abs(height) < 30:
print('Введите правильные данные')
else:
if height < 0:
countMan += 1
sumMan += height
else:
countWomen += 1
sumWomen += height
print(abs(int(sumMan/countMan)), int(sumWomen/countWomen))
var slova, bukvy, slovo : string;
i, b, k, c, j, l, kolvo, dlina1, dlina2 : integer;
a : array[1..50] of string;
begin
Writeln('Введите слова');
Readln(slova);
Writeln('Введите буквы');
Readln(bukvy);
dlina1 := length(slova);
dlina2 := length(bukvy);
k := 1;
for i := 1 to dlina1 do
if slova[i] = ' ' then
k := k + 1;
writeln(k);
b := 1;
i := 1;
while i <= length(slova) do
begin
if (slova[i] <> ' ') and (i <> length(slova)) then
slovo := slovo + slova[i]
else
begin
a[b] := slovo;
slovo := '';
b := b + 1;
end;
i := i + 1;
end;
a[k] := a[k] + slova[length(slova)];
b := 0;
l := 0;
for i := 1 to 50 do
if a[i] <> '' then
begin
slovo := a[i];
for k := 1 to length(slovo) do
for c := 1 to length(bukvy) do
if slovo[k] = bukvy[c] then
j := j + 1;
if j = length(slovo) then
begin
writeln(slovo);
l := l + 1;
j := 0;
end;
end;
if l = 0 then
writeln('NO');
end.
Объяснение: