home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / ctenari / cisloe / pocet.pas < prev    next >
Pascal/Delphi Source File  |  1997-03-06  |  1KB  |  52 lines

  1. (* Parametrem je soubor s cislem E. Program spocte vyskyt  *)
  2. (* jednotlivych cifer, jejich nejdelsi souvislou radu a    *)
  3. (* procentuelni podil.                                     *)
  4.  
  5. {$R+}
  6. program pocet;
  7. uses crt;
  8. var a:      array[0..9] of LongInt;
  9.     b:      array[0..9] of LongInt;
  10.     Sum:    Real;
  11.     i:      LongInt;
  12.     j:      Integer;
  13.     zn,szn: char;
  14.     fil:    file of char;
  15.  
  16. procedure test;
  17. {=============}
  18. begin
  19.   if i=1 then exit;
  20.   if a[j]<i then a[j]:=i;
  21.   i:=1;
  22.   szn:=zn;
  23. end;
  24.  
  25. begin
  26.   for i:=0 to 9 do a[i]:=0;
  27.   for i:=0 to 9 do b[i]:=0;
  28.   assign(fil,ParamStr(1));
  29.   {$I-} reset(fil); {$I+}
  30.   if ioresult<>0 then exit;
  31.   szn:=#0;
  32.   i:=0;
  33.   while not eof(fil) do begin
  34.     read(fil,zn);
  35.     j:=ord(zn)-ord('0');
  36.     if (j<0)or(j>9) then Continue;
  37.     inc(b[j]);
  38.     if zn=szn then inc(i)
  39.               else test;
  40.   end;
  41.   close(fil);
  42.   clrscr;
  43.   writeln;
  44.   writeln;
  45.   Sum:=0.0;
  46.   for i:=0 to 9 do
  47.     Sum:=Sum+b[i];
  48.   for i:=0 to 9 do
  49.     writeln(i:3,a[i]:3,b[i]:6,(b[i]*100.0/Sum):10:4,'%');
  50. end.
  51.  
  52.