1370题,哪位可以看看我哪出问题了bulid by shanno at 2019-11-19 13:13
Rating:1006
#include <iostream>
using namespace std;
int a[100005];
int main()
{
	int n,i,max1,max2,min1,min2,max,min,x;
	cin>>n;
	
	for(i=1;i<=n;i++)
	cin>>a[i];


	for(i=1;i<=n;i++)
	{
		if(i==1)
		{
			min=a[i+1]-a[i];
			max=a[n]-a[i];
			cout<<min<<" "<<max<<endl;
		}
		else if(i==n)
		{
			min=a[n]-a[n-1];
			max=a[n]-a[1];
			cout<<min<<" "<<max<<endl;
		}
		
		else
		{
			min1=a[i]-a[i-1];
			min2=a[i+1]-a[i];
			max1=a[i]-a[1];
			max2=a[n]-a[i];
			if(min1<min2)
			min=min1;
			else
			min=min2;
			if(max1>max2)
			max=max1;
			else
			max=max2;
			cout<<min<<" "<<max<<endl;
		}
		
	}

	return 0;
}
回复
要回复,请先登录

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: