1、
#include <stdio.h>
# define NUMBER 80
int main(void)
{
int a[NUMBER];
int number;
puts("please input the number of the student.");
do
{
printf("number of student = ");
scanf("%d", &number);
if (number < 1 | number > NUMBER)
{
printf("\athe san of number is 1-%d\n", NUMBER);
}
}
while ( number < 1 | number > NUMBER);
printf("please input %d student scores.\n", number);
int i;
for (i = 0; i < number; i++)
{
do
{
printf("%dst = ", i + 1);
scanf("%d", &a[i]);
if (a[i] < 0 | a[i] > 100)
printf("the score range is 0-100\n");
}
while (a[i] < 0 | a[i] > 100);
}
puts("-----\n-----\n-----");
int b[11] = {0};
for (i = 0 ; i < number; i++)
{
if (a[i]/10 == 0)
b[0]++;
if (a[i]/10 == 1)
b[1]++;
if (a[i]/10 == 2)
b[2]++;
if (a[i]/10 == 3)
b[3]++;
if (a[i]/10 == 4)
b[4]++;
if (a[i]/10 == 5)
b[5]++;
if (a[i]/10 == 6)
b[6]++;
if (a[i]/10 == 7)
b[7]++;
if (a[i]/10 == 8)
b[8]++;
if (a[i]/10 == 9)
b[9]++;
if (a[i]/10 == 10)
b[10]++;
}
puts(" destribution plot ");
printf(" 100: ");
for (i = 0; i < b[10]; i++)
putchar(‘*‘);
putchar(‘\n‘);
int j;
for (i = 9; i >=0; i--)
{
printf("%d-%d", i * 10, i * 10 + 10);
putchar(‘:‘);
for (j = 0; j < b[i]; j++)
putchar(‘*‘);
putchar(‘\n‘);
}
return 0;
}
原文:https://www.cnblogs.com/liujiaxin2018/p/14374356.html