home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
ctenari
/
cisloe
/
pocet.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-03-06
|
1KB
|
52 lines
(* Parametrem je soubor s cislem E. Program spocte vyskyt *)
(* jednotlivych cifer, jejich nejdelsi souvislou radu a *)
(* procentuelni podil. *)
{$R+}
program pocet;
uses crt;
var a: array[0..9] of LongInt;
b: array[0..9] of LongInt;
Sum: Real;
i: LongInt;
j: Integer;
zn,szn: char;
fil: file of char;
procedure test;
{=============}
begin
if i=1 then exit;
if a[j]<i then a[j]:=i;
i:=1;
szn:=zn;
end;
begin
for i:=0 to 9 do a[i]:=0;
for i:=0 to 9 do b[i]:=0;
assign(fil,ParamStr(1));
{$I-} reset(fil); {$I+}
if ioresult<>0 then exit;
szn:=#0;
i:=0;
while not eof(fil) do begin
read(fil,zn);
j:=ord(zn)-ord('0');
if (j<0)or(j>9) then Continue;
inc(b[j]);
if zn=szn then inc(i)
else test;
end;
close(fil);
clrscr;
writeln;
writeln;
Sum:=0.0;
for i:=0 to 9 do
Sum:=Sum+b[i];
for i:=0 to 9 do
writeln(i:3,a[i]:3,b[i]:6,(b[i]*100.0/Sum):10:4,'%');
end.