输入某班学生某门课的成绩(最多不超过40人,具体人数由用户键盘输入),用函数编程统计不及格人数。

#include<stdio.h>
{
int i,n,count;
cout<<"please input the number of the student(less than 40):";
cin>>n;
i=n;
int a[i];
cout<<"please input the students' score"<<endl;
for(i=1;i<=n;i++)
{
cin>>a[i];
if (a[i]<60)
count++;
}
cout<<"不及格的人数是"<<count<<endl;

}
知道上面毛病多,就是想问人数不确定,数组元素个数不确定,该如何定义数组

C++的活直接用 int *a=new int[i];就行了
温馨提示:答案为网友推荐,仅供参考
相似回答