VC++下的求多个同学的平均成绩然后求低于它的,打印出来(不知道同学的个数的)
#include <stdio.h>
int main()
{
int num, i; //变量定义
float *score, aver, sum = 0;
printf("Input the number of the scores:"); //输入同学个数
scanf("%d", &num);
if(num > 0)
{
score = new float[num]; //申请存储空间
for(i=0; i<num; i++) //输入成绩,并求和
{
printf("Score %d:/t", i+1); //i+1,序号从1开始
scanf("%f", score+i);
sum += *(score+i);
}
aver = sum/num; //计算平均成绩
printf("The average is score : %.2f./n",aver); //输出平均成绩
printf("The lower scores are:/n");
for(i=0; i<num; i++) //循环输出低于平均成绩的同学序号