#include<stdio.h>
static int print1(char z[]);
/* 打印输入中各字符出现频率的直方图 */
int main(void)
{
int c;
char z[128] = { 0 };
freopen("C:\\\\Users\\wwwzh\\Desktop\\data.in", "r", stdin);
freopen("C:\\\\Users\\wwwzh\\Desktop\\data.out", "w", stdout);
while ((c = getchar()) != EOF)
{
z[c]++;
}
print1(z);
return 0;
}
/* 按ASCLL码打印 */
static int print1(char z[])
{
int max, i, j;
max = z[0];
for (i = 1; i < 128; i++)
if (max < z[i])
max = z[i];
if (max == 0)
return 0;
printf("字符数目\n");
for (i = 1; i <= max; max--)
{
if (max == 0)
break;
printf("%4d|", max);
for (j = 0; j < 128; j++)
{
if (z[j] != 0)
{
if (z[j] >= max)
printf(" # ");
else
printf(" ");
}
}
putchar('\n');
}
printf("%4d|", 0);
for (j = 0; j < 128; j++)
{
if (z[j] != 0)
if (j == ' ')
printf("spa");
else if (j == '\n')
printf("\\n ");
else if (j == '\t')
printf("\\t ");
else
printf(" %c ", j);
}
printf("出现字符\n");
return 0;
}
/*
Enjoy that uniquenesss1
You do not have to pretend in order to seem more like someone else
Our bodies grow and muscles develop with the intake of adequate nutritious food
*/