#include <stdio.h> #define NUMBER 80 //人数上限 int main(void) { int i, j; int num;//实际人数 int score[NUMBER];//学生分数 int fenbu[11] = {0};//分布图 printf("请输入学生人数: "); do { scanf("%d", &num); if (num < 1 || num > NUMBER) printf("\a人数范围[1 to %d]: ", NUMBER); } while (num < 1 || num > NUMBER); puts("请输入学生的分数:"); for (i = 0; i < num; i++) { printf("No.%2d: ", i + 1); do { scanf("%d", &score[i]); if (score[i] < 0 || score[i] > 100) printf("\a分数范围[1 to 100]: "); } while (score[i] < 0 || score[i] > 100); fenbu[score[i] / 10]++; /*这句我看不懂*/ } puts("\n ★分布图★"); printf(" 100: "); for (j = 0; j < fenbu[10];j++); /*这句也是,我看不懂*/ putchar('*'); putchar('\n'); for (i = 9; i >= 0; i--) { printf("%3d - %3d: ", i * 10, i * 10 + 9); for (j = 0; j < fenbu[i]; j++)/*还有这一句,我不懂*/ putchar('*'); putchar('\n'); } return 0; }
KXFT
相关分类