描述 Cloud是个喜欢探险的程序员,在一次探险的时候,偶然发现了一些残缺的文件。以下是第二份残缺文件上的代码,请帮助他补全程序。(有星号的地方需要补全)

        #include <iostream>
    using namespace std;







    double average;
    ***** *****(*****)
    {
        int x,themax,sum,i;
        cin>>x;
        *****;
        sum=x;
        for(i=*****;i<=*****;i++)
        {
            cin>>x;
            if(x>themax)
                *****;
            sum+=x;
        }
        average=*****;
        return *****;
    }
    void main()
    {
        int n,max;
        cin>>*****;
        max=find(*****);
        cout<<*****<<' '<<average<<endl;
    }

输入
输入要计算的数字个数n,再依次输入n个整数。
输出
n个数中的最大值和平均值
难度
较难
输入示例
5
2 3 1 8 4
输出示例
8 3.6

#include <iostream>
using namespace std;
double average;
int find(int n) {
    int x,themax,sum,i;
    cin>>x;
    themax=x;
    sum=x;
    for(i=2; i<=n; i++) {
        cin>>x;
        if(x>themax)
            themax=x;
        sum+=x;
    }
    average=sum*1.0/n;
    return average;
}
void main() {
    int n,max;
    cin>>n;
    max=find(n);
    cout<<max<<' '<<average<<endl;
}