Создать текст. Вывести те слова текста, которые отличны от последнего слова и удовлетворяют следующему свойству: слово совпадает с конечным отрезком латинского алфавита (z, yz, xyz и т.д.) — Pascal(Паскаль)

uses crt;
const razd:set of char=[' ','.',',',':',';','!'];
var st,buf,alpha:string;
i,k:integer;
m:array[1..255]of string;
begin
 clrscr;
 k:=0;
 alpha:='abcdefghijklmnopqrstuvwxyz';
 readln(st);
 
 repeat
  if (st[1] in razd) or (length(st)=0) then while st[1] in razd do delete(st,1,1)
  else
  begin
   while (not (st[1] in razd)) and (length(st)>0) do
   begin
    buf:=buf+st[1];
    delete(st,1,1);
   end;
  
  inc(k);
  m[k]:=buf;
  buf:='';
 
 end;
 until (length(st)=0) and (length(buf)=0);
 for i:=1 to k-1 do if (m[i]<>m[k]) and (pos(m[i],alpha)>0) and (m[i][length(m[i])]='z') then write(m[i],' ');
end.

Leave a Comment

− 1 = 3