12-01-2007, 06:25 PM
program count_char; { count char generated }
var stg, stg1 : string;
a,b,c,d,e,f,g,h,i,j,k,n,x : integer;
procedure count; (* count the first char of string *)
begin
n:=n+1;
case stg[1] of
'a': a:=a +1;
'b': b:=b +1;
'c': c:=c +1;
'd': d:=d +1;
'e': e:=e +1;
'f': f:=f +1;
'g': g:=g +1;
'h': h:=h +1;
'i': i:=i +1;
'j': j:=j +1;
end;
end;
procedure chart;
begin
write('a: '); for x:=1 to a do write('*'); writeln;
write('b: '); for x:=1 to b do write('*'); writeln;
write('c: '); for x:=1 to c do write('*'); writeln;
write('d: '); for x:=1 to d do write('*'); writeln;
write('e: '); for x:=1 to e do write('*'); writeln;
write('f: '); for x:=1 to f do write('*'); writeln;
write('g: '); for x:=1 to g do write('*'); writeln;
write('h: '); for x:=1 to h do write('*'); writeln;
write('i: '); for x:=1 to i do write('*'); writeln;
write('j: '); for x:=1 to j do write('*'); writeln;
end;
begin
randomize;
stg:=' ';
n:=0; a:=0; b:=0; c:=0; d:=0; e:=0; f:=0; g:=0; h:=0; i:=0; j:=0;
while stg[1]<>'k' do
begin
stg:=chr(random(11)+1+96);
count
end;
writeln('Number of entries =',n-1:4);
writeln('Frequence of the characters generated');
chart;
end.
var stg, stg1 : string;
a,b,c,d,e,f,g,h,i,j,k,n,x : integer;
procedure count; (* count the first char of string *)
begin
n:=n+1;
case stg[1] of
'a': a:=a +1;
'b': b:=b +1;
'c': c:=c +1;
'd': d:=d +1;
'e': e:=e +1;
'f': f:=f +1;
'g': g:=g +1;
'h': h:=h +1;
'i': i:=i +1;
'j': j:=j +1;
end;
end;
procedure chart;
begin
write('a: '); for x:=1 to a do write('*'); writeln;
write('b: '); for x:=1 to b do write('*'); writeln;
write('c: '); for x:=1 to c do write('*'); writeln;
write('d: '); for x:=1 to d do write('*'); writeln;
write('e: '); for x:=1 to e do write('*'); writeln;
write('f: '); for x:=1 to f do write('*'); writeln;
write('g: '); for x:=1 to g do write('*'); writeln;
write('h: '); for x:=1 to h do write('*'); writeln;
write('i: '); for x:=1 to i do write('*'); writeln;
write('j: '); for x:=1 to j do write('*'); writeln;
end;
begin
randomize;
stg:=' ';
n:=0; a:=0; b:=0; c:=0; d:=0; e:=0; f:=0; g:=0; h:=0; i:=0; j:=0;
while stg[1]<>'k' do
begin
stg:=chr(random(11)+1+96);
count
end;
writeln('Number of entries =',n-1:4);
writeln('Frequence of the characters generated');
chart;
end.