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-%d\n",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 = %d\n", 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; }