Var Text,S:string; n,k:boolean; i:integer; Begin Write('Введите текст на русском языке: ');ReadLn(Text); Text:=LowerCase(Text)+' '; // перевоит текст в нижний регистр WriteLn(Text); // показывает действие предыдущей строки For i:= 1 to Length(Text) do Begin if ('а' <= Text[i])and(Text[i] <= 'я')or(Text[i] = 'ё') then S:=S+Text[i] // записываем русские буквы в S else // как только встречаем другой символ, проверяем, if Length(S) > 0 then // есть ли в S хоть одна буква, Begin // и если есть, то проверяем условие задачки, и выводим слово на экран, если оно истинно if (S[1] in 'бвгджзйклмнпрстфхцчшщ')and(S[Length(S)] in 'аоэиуыеёюя') then WriteLn(S); S:=''; // далее обнуляем S End; End; End.
Пример работы программы:
Введите текст на русском языке: Дан произвольный текст на русском языке. Написать программу, которая выводит слова, начинающиеся на согласную и заканчивающиеся гласной буквой. дан произвольный текст на русском языке. написать программу, которая выводит слова, начинающиеся на согласную и заканчивающиеся гласной буквой. на программу которая слова начинающиеся на согласную заканчивающиеся
{ FreePascal 2.6.4}
program test;
uses
crt;
var
a, b, c, d : integer;
f : longint;
procedure swap (var x : integer; var y : integer);
var z : integer;
begin
z := x;
x := y;
y := z;
end;
function nod (m, n : integer) : integer;
begin
while m<>n do begin
if m>n
then
m:=m-n
else
n:=n-m;
end;
nod := m;
end;
function max (a,b : integer) : integer;
begin
if a>b
then max := a
else max := b;
end;
function min (x, y, z : integer) : integer;
var m : integer;
begin
m := x;
if y<m then m := y;
if z<m then m := z;
min := m;
end;
function mypow (a, b : integer) : integer;
var e, f : integer;
begin
f := 1;
for e:=1 to b do f := f*a;
mypow := f;
end;
function fact(a : integer) : longint;
var
i : integer;
res : longint;
begin
res := 1;
for i := 1 to a do res := res*i;
fact := res;
end;
begin
clrscr;
writeln('Test of function SWAP');
write('Input A: ');
readln(a);
write('Input B: ');
readln(b);
swap(a, b);
writeln('A=', a, ', B=', b);
writeln;
writeln('Test of function NOD');
write('Input A: ');
readln(a);
write('Input B: ');
readln(b);
c := nod(a, b);
writeln('NOD(', a, ',', b, ')=', c);
writeln;
writeln('Test of function MAX');
write('Input A: ');
readln(a);
write('Input B: ');
readln(b);
c := max(a, b);
writeln('MAX(', a, ',', b, ')=', c);
writeln;
writeln('Test of function MIN');
write('Input A: ');
readln(a);
write('Input B: ');
readln(b);
write('Input C: ');
readln(c);
d := min(a, b, c);
writeln('MIN(', a, ',', b, ',', c, ')=', d);
writeln;
writeln('Test of function POW');
write('Input A: ');
readln(a);
write('Input B: ');
readln(b);
c := mypow(a, b);
writeln('POW(', a, ',', b, ')=', c);
writeln;
writeln ('Test of function FACT (not large than 12!)');
write('Input A: ');
readln(a);
f := fact(a);
writeln(a, '!=', f);
writeln;
readkey;
end.