JAVA CCF-201809-1 卖菜

欢迎访问我的CCF认证解题目录


题目描述

在这里插入图片描述


思路过程

水题。。


代码

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] price = new int[n];
		for ( int i = 0; i < price.length; i++ ) price[i] = in.nextInt();
		
		//按规则输出
		for ( int i = 0; i < price.length; i++ ) {
			if ( i == 0 ) System.out.print((price[0]+price[1])/2+" ");
			else if ( i == price.length-1 ) System.out.print((price[i]+price[i-1])/2+" ");
			else System.out.print((price[i]+price[i-1]+price[i+1])/3+" ");
		}
	}

}
发布了60 篇原创文章 · 获赞 0 · 访问量 2118

猜你喜欢

转载自blog.csdn.net/weixin_43732798/article/details/104239103