home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume17 / hill / kappa.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-08  |  642 b   |  33 lines

  1. ^X/* Kappa: utility program
  2. ^X    Prints a table of character frequencies drawn from stdin.
  3. ^X;The table appears in natural order.
  4. ^X;Frequencies are per 1000 characters.
  5. ^X*/
  6. ^X
  7. ^X# include <stdio.h>
  8. ^X
  9. ^Xlong table[256];
  10. ^Xlong total;
  11. ^X
  12. ^Xmain()
  13. ^X    {
  14. ^X;int ch;
  15. ^X    int i;
  16. ^X    int lcmpr();
  17. ^X
  18. ^X    while ((ch = getchar()) != EOF) {
  19. ^X;;table[ch]++;
  20. ^X        total++;
  21. ^X        }
  22. ^X    printf("Total: %ld\n\n", total);
  23. ^X    for (i = 0; i < 256; i++) {
  24. ^X;;table[i] *= 1000;
  25. ^X        table[i] /= total;
  26. ^X        }
  27. ^X    for (i = 0; i < 256; i++) {
  28. ^X;;printf("%3.3ld ", table[i]);
  29. ^X        if ((i + 1) % 16 == 0) putchar('\n');
  30. ^X        if ((i + 1) % 128 == 0) putchar('\n');
  31. ^X        }
  32. ^X    }
  33.