Ввести предложение и вывести слова оканчивающиеся на букву- Pascal(Паскаль)

Program Dlinna_slov_stroki;
var
    a:array[1..80] of string;
        str,sl,by,by1:string;
   l:array[1..80] of integer;
              maxl,i:integer;
           spice,tochka:char;
                 p,q,st,sch:byte;
begin
maxl:=0; p:=0; spice:=' '; tochka:='.'; sch:=0;
writeln('Введите предложение:');
readln(str);
p:=pos(tochka,str);                          
if p>0 then str:=copy(str,1,p-1);  
repeat
st:=length(str);
by1:=copy(str,st,st);
if by1=spice then str:=copy(str,1,st-1)
else i:=1;
until i=1;
i:=0;         
repeat
p:=pos(spice,str);                          
   if p=1 then                               
          Delete(str,p,1)                    
  else begin 
         i:=i+1;
         a[i]:=copy(str,1,p-1);
         Delete(str,1,p);
         l[i]:=length(a[i]);
         if maxl<l[i] then maxl:=l[i];   
       end;
until  p=0;
if l[1]=0 then write ('Введенная строка пуста')
else begin
repeat
     writeln ('Будем проводить проверку слов? 1 - да, 0 - нет');
     readln(q);
until (q=1) or (q=0);
     if q=0
     then begin
          writeln ('Проверка не была произведена');
          for p:=1 to i do begin
          writeln('слово №',p:2,':',a[p]:maxl,' (Длина слова =',l[p]:3,') Примечание: отсутсвует');              
          end;
          end
     else begin
          writeln ('Введите 1 символ для сравнения окончания слова');
          readln (by);
          st:=length(by);
          p:=pos(spice,by); 
          if (st=0) or (st>=2)or (p=1) then begin
                                            writeln ('Проверка не была произведена');
                                            writeln ('Строка пуста или было введено более 1 символа для проверки');
                                            sl:='отсутствует'
                                            end
          else begin
               for p:=1 to i do begin
               st:=length(a[p]);
               by1:=copy(a[p],st,st);
               if by=by1 then begin
                              sl:='Слово оканчивается на заданную букву';
                              inc(sch);
                              end
               else sl:='Слово не оканчивается на заданную букву';
               writeln('слово №',p:2,':',a[p]:maxl,' (Длина слова =',l[p]:3,') Примечание: ',sl);  
               end;
               writeln ('Количество слов удовлетворяющих условию: ',sch);
               end;
end;
end;
readln;
end.

Leave a Comment

59 − 53 =