• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

c语言 5-9

开发技术 开发技术 4天前 10次浏览

1、

#include <stdio.h>

#define NUMBER 1000

int main(void)
{
    int i, j, num, a[NUMBER], max, b[11] = {0};
    do
    {
        printf("num = "); scanf("%d", &num);
        if(num < 1 | num > NUMBER)
            printf("the range of num is 1-%dn",NUMBER);
    }
    while(num < 1 | num > NUMBER);
    
    puts("please input the scores of the students.");
    for(i = 0; i < num; i++)
    {
        do
        {
            printf("NO.%d = ", i + 1); scanf("%d", &a[i]);
            if(a[i] < 0 | a[i] > 100)
                puts("the range of score is 0-100.");
        }
        while(a[i] < 0 | a[i] > 100);
        
        b[a[i] / 10]++;
    }
    max = b[0];
    for(i = 0; i < 11; i++)
    {
        if(b[i] > max)
            max = b[i];
    }

    printf("max = %dn", max);
    puts("====================distribution plot==============================");
    for(i = max; i > 0; i--)
    {
        for(j = 0; j < 11; j++)
        {
            if(b[j] >= i)
                printf("    *");
            else
                printf("     ");
        }
        putchar('n');
    }
    
    puts("---------------------------------------------------------------------");
    for(i = 0; i < 11; i++)
    {
        printf("%5d", i * 10);
    }
    putchar('n');
    return 0;
}

c语言 5-9

 


程序员灯塔
转载请注明原文链接:c语言 5-9
喜欢 (0)