#include <stdio.h>
main()
{
struct {char c; int t;} cp[256]={0}, tmp;
int i, j, count;
char c;
for (count=0; (c=getchar())!='\n'; ++count)
++cp[c].t;
for (i=0; i<256; ++i)
cp[i].c = i;
for (i=0; i<255; ++i)
{
for (j=i+1; j<256; ++j)
{
if (cp[i].t < cp[j].t)
{
tmp = cp[i];
cp[i] = cp[j];
cp[j] = tmp;
}
}
}
printf("字符总数: %d\n", count);
printf("字符\t次数\t占比\n");
for (i=0; i<256; ++i)
if (cp[i].t > 0)
printf("%c\t%d\t%f\n", cp[i].c, cp[i].t, (float)cp[i].t/count);
}