思路:
需要两个数组,一个保存原始数据
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int shop[] = new int[n];//保存原始数据
int store[] = new int[n];
for(int i=0;i<n;i++) {
shop[i] = sc.nextInt();
}
store[0] = (shop[0]+shop[1])/2;
store[n-1] = (shop[n-2]+shop[n-1])/2;
for(int j=1;j<n-1;j++) {
store[j] = (shop[j-1]+shop[j]+shop[j+1])/3;
}
sc.close();
for(int k=0;k<n;k++) {
System.out.print(store[k] + " ");
}
}
}