是关于数组和广义表的
开个101长度的数组
#include <stdio.h>
#include <time.h> //包含一些时间的头文件用于产生随机数
#include <stdlib.h>
#define M 1000 //定义学生的人数
int main(int argc,char *argv[])
{
srand(time(0));
int student[M] = {0};//定义数组记录M个学生的成绩
int count[101] = {0};//定义数组统计0~100各分数的次数
int i = 0;
for(i = 0; i < M ; i++)//随机产生1000个0~100的学生成绩
student[i] = rand()%101;
for(i = 0; i < M ; i++)
count[student[i]]++;//如果student[i] = 25; 则 count[25]++; 意思是分数25的统计加一,其他依次类推
for(i = 0 ; i < 101; i++)
printf("%d分的学生有%d个人\n",i,count[i]);
return 0;
}
VC6++测试效果: