循环调用此函数即可
void Fun(int &index, float &max, float &min, float &ave)
{
float var ;
std::cout << "学生成绩:" << std::endl;
std::cin >> var;
if (index == 0) //处理第一个学生
{
index++;
max = min = ave = var;
std::cout << index << var << max << ave << min << std::endl;
return;
}
min = var<min?var:min;
max = var>max?var:max;
ave = (index*ave + var)/(index+1);
index++;
std::cout << index << var << max << ave << min << std::endl;
}