SHARE
TWEET

Untitled

EnotAfanka Oct 13th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top