Дан текст . Определить , сколько в нем предложений — Pascal(Паскаль)

const
 simv=['!', '?', '.'];
var
 st: string;
 i, count: integer;
begin
 readln(st);
  for i:=1 to length(st) do
   begin
    if st[i] in simv then
     begin
      inc(count);
     end;
   end;
 writeln('Предложений - ', count);
end.
const
 simv=['!', '?', '.'];
var
 st: string;
 i, count: integer;
 f: text;
begin
 assign(f, 'C:\Documents and Settings\Admin\Рабочий стол\File.txt');
 reset(f);
  while not EOF(f) do
   begin
    readln(f, st);
     for i:=1 to length(st) do
      begin
       if st[i] in simv then
        begin
         inc(count);
        end;
      end;
   end;
 close(f);
 writeln('Предложений - ', count);
end.
var
 s: string;
 i, count: byte;
Begin
 s:='Бла-бла? Да! Бла-бла!! Бла-бла-бла... Бла?! Бла-бла...';
 s:=s+' ';
 count:=0;
 For i:=1 to length(s)-1 do
  if (s[i] in ['.','!','?']) and (s[i+1] = ' ') then inc(count);
 Writeln('Предложений: ',count);
End.
var
 s: string;
 i, count,k: byte;
Begin
 s:='....   бююю. Бла-бла? Да! Бла-бла!! Бла-бла-бла... Бла?! Бла-бла...  ...   .. ';
 k:=0;
 i:=1;
 while s[i] in ['.',',','!',':','?',' '] do
 begin
  inc(i);
  inc(k);
 end;
 delete(s,1,k);
 k:=0;
 i:=length(s);
 while s[i] in ['.',',','!',':','?',' '] do
 begin
  dec(i);
  inc(k);
 end;
 delete(s,length(s)-k+1,k);
 writeln(s);
 count:=0;
 For i:=1 to length(s)-1 do
  if (s[i] in ['.','!','?']) and not((s[i+1] in ['.','!','?'])) then inc(count);
 Writeln('Ïðåäëîæåíèé: ',count+1);
End.
const
 ABC = ['A'..'Z','А'..'Я'];
 DI = ['.','!','?'];
var
 s: string;
 i, count: byte;
Begin
 s:='....   бююю ';
 i:=1;
 while (not (upcase(s[1]) in ABC)) and (length(s) > 2) do
  delete(s,1,1);
 while pos('  ',s)<>0 do
  delete(s,pos('  ',s),1);
 For i:=length(s) downto 2 do
  if (upcase(s[i]) in ABC) and (s[i-1] in DI) then insert(' ',s,i);
 count:=0;
 For i:=1 to length(s)-2 do
  if (s[i] in DI) and (s[i+1] = ' ') and (upcase(s[i+2]) in ABC) then inc(count);
 Writeln('Предложений: ',count+1);
End.

Leave a Comment

14 + = 21