Question number: | 201809-1 |
Question name: | Sell vegetables |
time limit: | 1.0s |
Memory limit: | 256.0MB |
Problem Description: | Problem Description There are n shops selling vegetables on one street, arranged in a row in the order of 1 to n, and these shops all sell one kind of vegetable. Input format The first line of input contains an integer n, which represents the number of stores. Output format Output a row, containing n positive integers, indicating the prices of the dishes in each store on the second day in turn. Sample input 8 Sample output 2 2 1 3 4 9 10 13 Data size and convention For all evaluation use cases, 2 ≤ n ≤ 1000, the price of the food in each store on the first day is a positive integer not exceeding 10,000. |
import java.util.Scanner;
public class 卖菜 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
b[0]=(a[0]+a[1])/2;
b[n-1]=(a[n-2]+a[n-1])/2;
for(int i=1;i<n-1;i++){
b[i]=(a[i-1]+a[i]+a[i+1])/3;
}
for(int i=0;i<n;i++){
System.out.print(b[i]+" ");
}
}
}