4.BASIC-4
数列特征(100分)
AC的C++代码如下:
#include <iostream>
using namespace std;
int a[10000];
int main()
{
int n;
int sum = 0;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> a[i];
}
int max = a[0];
int min = a[0];
for(int i=0;i<n;i++)
{
if(a[i]<min)
{
min = a[i];
}
if(a[i]>max)
{
max = a[i];
}
sum += a[i];
}
cout << max << endl;
cout << min << endl;
cout << sum << endl;
return 0;
}