Exemplo n.º 1
0
//第二条线在两个点的左边,共三条线
bool PathFind::Left(const Point& first,const Point& second)
{  
	for(int i=first.Y-1;i>=0;i--)//循环Y轴(横线)
	{
		if(A[first.X][i]!=ZERO)
		{
			return false;
		}
		Point first1(first.X,i);//第一个拐点
		Point second1(second.X,i);
		if(A[second1.X][second1.Y]!=ZERO)
		{
			return false;
		}
		bool isOK=SameY(first1,second1);//同竖线 
		if(!isOK)
		{
			continue;
		} 
		isOK=SameX(second1,second);//同横线 
		if(isOK)//寻路成功
		{ 
			centerPoint.Clear();
			centerPoint.AddPoint(first1);
			centerPoint.AddPoint(second1); 
			return true;
		} 
	}
	return false;
}
Exemplo n.º 2
0
		void testCase11(){
			int arr1[] = { 0, 1, 3, 5, 9 }, arr2[] = { 2, 4, 6, 7, 8 };
			stdL<double> first1(std::begin(arr1), std::end(arr1)), second1(std::begin(arr2), std::end(arr2));
			tsL<double> first2(std::begin(arr1), std::end(arr1)), second2(std::begin(arr2), std::end(arr2));

			first1.merge(second1);
			first2.merge(second2);
			assert(TinySTL::Test::container_equal(first1, first2));
		}
Exemplo n.º 3
0
bool PathFind::Right(const Point& first,const Point& second)
{
	for(int i=first.Y+1;i<second.Y;i++)
	{
		if(A[first.X][i]!=ZERO)
		{
			return false;
		}
	}
	for(int i=second.Y;i<column;i++)
	{
		if(A[first.X][i]!=ZERO)
		{
			return false;
		}
		Point first1(first.X,i);//第一个拐点
		Point second1(second.X,i);//第二个拐点
		if(A[second1.X][second1.Y]!=ZERO)
		{
			return false;
		}
		bool isOK=SameY(first1,second1);//同竖线 
		if(!isOK)
		{
			continue;
		} 
		isOK=SameX(second1,second);//同横线 
		if(isOK)//寻路成功
		{
			//do something
			centerPoint.Clear();
			centerPoint.AddPoint(first1);
			centerPoint.AddPoint(second1); 
			return true;
		}
	}
	return false;
}