CCF 201809-1 卖菜
作者:互联网
#include <iostream> #include <bits/stdc++.h> #include <string> using namespace std; int main() { int n; cin>>n; vector<int> a; for(int i=0;i<n;i++) { int temp; cin>>temp; a.push_back(temp); } int *b = (int *)malloc(sizeof(int)*n); for(int i=0;i<n;i++) { if(i==0) b[i]=(int)((a[i+1]+a[i])*1.0/2); else if(i==n-1) b[i]=(int)((a[i-1]+a[i])*1.0/2); else b[i]=(int)((a[i-1]+a[i+1]+a[i])*1.0/3); } for(int i=0;i<n;i++) { if(i==0) cout<<b[i]; else cout<<" "<<b[i]; } cout<<endl; }
标签:std,main,malloc,CCF,temp,int,201809,include,卖菜 来源: https://www.cnblogs.com/-Asurada-/p/14413459.html