#include <iostream> #include <cstdio> using namespace std; int main() { int n, sum = 0; cin >> n; for(int i = 0; i < n; i++) { int a; cin >> a; sum += a; } cout <<sum<<" "<<sum/n<<endl; return 0; }
1、MA移动平均数 def ma(data,w):res=[]for i in range(len(n)-w+1):ave=0for j in range(w):ave+=data[i+j]ave/=wres.append(ave)return resn=[1437,1532,1503,1498,1524,1552,1542,1632]res1=ma(n,3)res2=ma(n,5)