Advertisement
EnotAfanka

Untitled

Oct 13th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.44 KB | None | 0 0
  1. var i,max,sum:integer;
  2.     s:string;
  3. begin
  4.   writeln('Enter sentence: ');
  5.   readln(s);
  6.   max:=0;
  7.   sum:=0;
  8.   for i:=1 to length(s) do
  9.     begin
  10.       if s[i]='a' then sum:=sum+1 else
  11.         begin
  12.           if sum<>max then
  13.             begin
  14.               max:=sum;
  15.               sum:=0;
  16.             end
  17.         end
  18.     end;  
  19.   if s[length(s)]='a' then
  20.     if sum>max then max:=sum;
  21.   writeln('Longest sequence: ', max);
  22. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement