题目描述:
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int PI = acos(-1);
const int E = exp(1);
const int MOD = 1e9+7;
const int MAX = 1e3+5;
int n,x;
int a1[MAX];
int a2[MAX];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a1[i];
}
for(int i = 0; i < n; i++)
{
if(i == 0)
{
a2[i] = (a1[i]+a1[i+1]) / 2;
}
else if(i == n-1)
{
a2[i] = (a1[i]+a1[i-1]) / 2;
}
else
{
a2[i] = (a1[i]+a1[i-1]+a1[i+1]) / 3;
}
}
for(int i = 0; i < n; i++)
{
cout << a2[i] << " ";
}
cout << endl;
return 0;
}