*个数是如何知道的~~~~
for(j=0;j<count[grade];j++){
printf("%c",'*');
}
‘*’个数是如何知道的?
程序代码:
#include<stdio.h> int main() { int score[40],count[11]={0}; int i,j,grade; for(i=0;i<40;i++) scanf("%d",&score[i]); for(i=0;i<40;i++) count[score[i]]++; printf("Grade\tCount\tHistogram\n"); for(grade=0;grade<40;grade++) { printf("%5d\t%5d\t",grade,count[grade]); for(j=0;j<count[grade];j++) { printf("%c",'*'); } printf("\n"); } return 0; }