impressive_i

Untitled

May 18th, 2020
329
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // example data in .txt file: ABCCAAACACCCCBCBCAACCCCCA
  2.  
  3. program p;
  4.  
  5. uses crt;
  6.  
  7. var filetxt : text;
  8.     Count_C_in_current_chain : integer;
  9.     i : integer;
  10.     S : String;
  11.     max_len_C : integer;
  12.     ch : char;
  13.    
  14. begin
  15.     assign(filetxt, 'test.txt');
  16.     reset(filetxt);
  17.    
  18.     max_len_C := 0;
  19.     Count_C_in_current_chain := 0;
  20.     while not eof(filetxt) do
  21.        begin
  22.           read(filetxt, Ch);
  23.           if( ch = 'C') then
  24.              Count_C_in_current_chain := Count_C_in_current_chain + 1
  25.           else
  26.              begin
  27.              if (Count_C_in_current_chain > max_len_C ) then
  28.                 begin
  29.                     max_len_C := Count_C_in_current_chain;
  30.                 end;
  31.              Count_C_in_current_chain := 0;
  32.              end;
  33.        end;
  34.  
  35.    write(' Max-length C-chain: ', max_len_C);
  36.    close(filetxt);
  37. end.
RAW Paste Data