任务描述
从键盘输入一个班(全班最多不超过30人)学生的某门课的成绩,输入学生信息并统计,当输入成绩为负值时,输入结束;输入结束后需要统计输入的学生人数并输出。
测试说明
示例如下:
输入学生信息的格式为:
#include <stdio.h>
#define ARR_SIZE 30
int NumScore(long num[], float score[]);
int main(void)
{
int n;
float score[ARR_SIZE];
long num[ARR_SIZE];
printf("Please enter num and score until score<0:\n");
n = NumScore(num, score);
printf("Total students:%d\n", n);
return 0;
}
int NumScore(long num[], float score[])
{
int i = 0;
for(i=0; i<ARR_SIZE; i++)
{
scanf("%ld %f", &num[i], &score[i]);
if(score[i] < 0)
break;
}
return i;
}