Enter five students in a course grades (indicated by a one-dimensional array), respectively function to achieve the following functions:

5 enter a course of student performance (represented by one-dimensional array), with each function to achieve the following functions:
Requirements: Results and number of the main transfer function by Student to the called function, using the parameter pointer form.
1) output of these five students in grade point average
2) Output 5 students in the highest score, lowest score

#include<iostream>
using namespace std;
int main()
{
	int i,n;
	int math[3];
	int max1(int a[],int n);
	cout<<"请输入学生的数量:"<<endl;
	cin>>n;
	cout<<"请输入三个同学的成绩:"<<endl;
	for(i=0;i<3;i++)
	{
		cin>>math[i];
	}
	max1(math,n);
	return 0;
}
int max1(int a[],int n)
{
	int sum=0;
	int max;
	max=a[0];
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if(max<a[i]) max=a[i];
	}
	cout<<"成绩总和为:"<<sum<<endl;
	cout<<"最大的成绩为:"<<max<<endl;
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_43803070/article/details/92792919