CSP考试 2018年9月第1题 卖菜 C++实现

CSP考试 2018年9月第1题 卖菜 C++实现 

 

#include <iostream>
using namespace std;
int a[1001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			cout<<(int)(a[0]+a[1])/2<<" ";
		}else if(i==(n-1))
		{
			cout<<(int)(a[n-1]+a[n-2])/2<<endl;
		}else
		{
			cout<<(int)(a[i-1]+a[i]+a[i+1])/3<<" ";
		}
	}	
	return 0;
}

 

相关文章:

  • 2022-12-23
  • 2021-10-05
  • 2021-06-18
  • 2021-11-17
  • 2022-01-01
  • 2021-11-28
  • 2021-09-08
  • 2022-12-23
猜你喜欢
  • 2021-05-19
  • 2021-05-29
  • 2022-01-05
  • 2021-11-28
  • 2021-12-02
  • 2021-07-31
  • 2022-12-23
相关资源
相似解决方案