Advertisement
Guest User

Untitled

a guest
Mar 15th, 2013
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var
  2.   mas:                 string;
  3.   c, tmp:              char;
  4.   i, j, count, max: integer;
  5.  
  6. begin
  7.   count := 0;
  8.   max   := 0;
  9.   write('Введите строку: ');
  10.   readln(mas);
  11.   tmp := chr(255);
  12.  
  13.   for i := 1 to length(mas) do
  14.   begin
  15.     c := mas[i];
  16.    
  17.     for j := 1 to length(mas) do
  18.     begin
  19.       if mas[j] = c then
  20.         inc(count);
  21.     end;
  22.    
  23.     if max <= count then
  24.     begin
  25.        if (max = count) and (tmp > c)then
  26.        begin
  27.            max := count;
  28.            tmp := c
  29.        end;
  30.        if max < count then
  31.        begin
  32.          max := count;
  33.          tmp := c
  34.        end
  35.     end;
  36.    
  37.     count := 0;
  38.   end;
  39.  
  40.   write('Самый популярный символ: ', tmp, ', встречается раз: ', max)
  41. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement