LINUX.ORG.RU

История изменений

Исправление mix_mix, (текущая версия) :

#include <stdio.h>
#include <ctype.h>

int main()
{
    int c, total = 0, table[26] = {0};
    const char *hist = "*********************";

    while ((c = getchar()) != EOF)
        if(isalpha(c)) total++,
            table[tolower(c) - 'a']++;
    
    for (c = 0; c < 26; c++) if (table[c])
        printf("%c: %5d %.*s\n", 'a' + c, table[c],
            (int) 20.0 * table[c] / total + 1, hist);
}

Исходная версия mix_mix, :

#include <stdio.h>
#include <ctype.h>

int main()
{
    int c, total = 0, table[26] = {0};
    const char *hist = "********************";

    while ((c = getchar()) != EOF)
        if(isalpha(c)) total++,
            table[tolower(c) - 'a']++;
    
    for (c = 0; c < 26; c++) if (table[c])
        printf("%c: %5d %.*s\n", 'a' + c, table[c],
            (int) 20.0 * table[c] / total, hist);
}