ETAONI HSRDLU WMCGFYBPVKXJQZ in calgary/book1
ETAONI HSRDLU MWCFGYPBVKXJQZ in silesia/dickens
EANITO RSLCDU MPHGFBYVWKXJZQ in maxcomp/world95.txt
ETHAON ISRDLU FMWYGCBPVKJZXQ in cantrbry_large/bible.txt
ETAION RSLHCD MUPGFBYWVKQXJZ in enwik8
ETAION RSLHDC MUPGFBYWVKQXJZ in enwik9
ETASIN ORLDCP UHMGFBWYKVXJQZ in Reuters 21578 corpus
Code:
// Print alphabet by decreasing frequency from file name args
// Public domain.
#include <stdio.h>
int main(int argc, char** argv) {
int t[26]={0}, c, n=0;
char buf[4096];
for (int i=1; i<argc; ++i) {
FILE* in=fopen(argv[i], "rb");
while (in && (n=fread(buf, 1, 4096, in))>0) {
for (int j=0; j<n; ++j) {
c=buf[j];
if (c>='a' && c<='z') ++t[c-'a'];
if (c>='A' && c<='Z') ++t[c-'A'];
}
}
if (in) fclose(in);
}
n=0;
for (int i=0; i<26; ++i) {
int b=0;
for (int j=1; j<26; ++j)
if (t[j]>t[b]) b=j;
printf("%c", b+'A');
if (i==5 || i==11) printf(" ");
n+=t[b];
t[b]=-1;
}
printf(" n=%d\n", n);
return 0;
}