home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
qtawkos2.zip
/
QTAUTL.ZIP
/
histogrm.exp
< prev
next >
Wrap
Text File
|
1990-04-23
|
763b
|
27 lines
# histogram - AWK, page 70 (Note short program at bottom of page run from
# command line to create random.txt with following command
# QTAwk "BEGIN{for(i=1;i<=200;i++)print(int(101*rand()));}" >random.txt
# and
# QTAwk -fhistogrm.exp random.txt
# or
# QTAwk "BEGIN{for(i=1;i<=200;i++)print(int(101*rand()));}" | QTAwk -fhistogrm.exp
#
# also can use AWKPLUS porgram random.exp
# QTAwk -random.exp | QTAwk -fhistogrm.exp
#
# input: numbers between 0 and 100
# output: histogram of deciles
#
{
x[int($1/10)]++;
}
END {
for ( i = 0 ; i < 10 ; i++ )
printf(" %2d - %2d: %3d %s\n", 10*i, 10*i+9, x[i], rep(x[i],"*"));
}
function rep(n,s, t) { #return string of n s's
# while ( n-- > 0 ) t = t s;
# return t;
return copies(s,n);
}