Guest User

Untitled

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