int main(){

	node_t *head1 = NULL;
		
	int len1 = 0;
	int len2 = 0;
	//insertElement(1,&head1);
	insertElement(2,&head1);
	insertElement(4,&head1);
	insertElement(2,&head1);
	insertElement(1,&head1);

	int mid = returnIndex(head1);
	
	checkPalindrome(&head1,mid);
	
	
	
	return 0;
}
示例#2
0
bool CMethod::sendPlane(vector<SCARD>& player,vector<SENDCARDS>& send,int  ID,int x,int y)
	{
	int  Customunsigned;
	if (ID==PLAYER_C)
		{
		Customunsigned =1;
		}else if(ID==PLAYER_A) Customunsigned =0;
	int tempIndex;
	SENDCARDS tempSend;
	if (!m_plane.empty())
		{
		for (int i=0;i<m_plane.size();i++)
			{
			if (m_plane[i].m_ISprimary==true&&((m_plane[i].max>m_sendArray.max&&
				(m_plane[i].max-m_plane[i].min==m_card.three-1))||m_noSendNum==2))
				{
				for (int j=m_plane[i].min,index=0;j<=m_plane[i].max;j++,index++)
					{
					for (int k=0;k<=2;k++)
						{
						tempIndex= returnIndex(player,j);
						tempSend.coord_x=x+index*60+k*20-100*Customunsigned;
						tempSend.coord_y=y;
						tempSend.ID=ID;
						tempSend.cx=player[tempIndex].cx;
						tempSend.cy=player[tempIndex].cy;
						send.push_back(tempSend);
						m_maxCard = m_plane[i].max;
						}
					}
				m_sendArray.type=PLANECARDS;
				m_sendArray.cardNum=(m_plane[i].max-m_plane[i].min+1)*3;
				deletePlayer(player,send,ID);
				return true;
				}
			}

		}

	return  false;
	}
示例#3
0
bool CMethod::DeleteComputerCard(vector<SCARD>& player,CARDTYPE type,vector<SENDCARDS>& send,int  ID,int x,int y)//删除电脑的牌
	{
	int  Customunsigned;
	if (ID==PLAYER_C)
	{
	 Customunsigned =1;
	}else if(ID==PLAYER_A) Customunsigned =0;
	int tempIndex;
	SENDCARDS tempSend;
	switch(type)
		{
		case SINGLECARD://单张
			if (!m_single.empty())//单张数组不等于空
			{
			  for (int i=0;i<m_single.size();i++)
			  {
			   if (m_single[i].m_ISprimary==true&&m_single[i].max>m_sendArray.max)
			   {
			        
					 tempIndex= returnIndex(player,m_single[i].max);
					 tempSend.coord_x=x;
					 tempSend.coord_y=y;
					 tempSend.ID=ID;
					 tempSend.cx=player[tempIndex].cx;
					 tempSend.cy=player[tempIndex].cy;
					 send.push_back(tempSend);
					 m_maxCard = m_single[i].max;
					 m_sendArray.cardNum=1;
					 m_sendArray.type=SINGLECARD;
					deletePlayer(player,send,ID);
					 return true;
			   }
			  }
			}
			break;
		case BOTHCARDS://对子
			if (!m_double.empty())//单张数组不等于空
				{
				for (int i=0;i<m_double.size();i++)
			  {
			  if (m_double[i].m_ISprimary==true&&m_double[i].max>m_sendArray.max)
				  {
				  for (int j=m_double[i].min;j<=m_double[i].max;j++)
					  {
					  for (int k=0;k<=1;k++)
					  {
					  tempIndex= returnIndex(player,j);
					  tempSend.coord_x=x+k*20-40*Customunsigned;
					  tempSend.coord_y=y;
					  tempSend.ID=ID;
					  tempSend.cx=player[tempIndex].cx;
					  tempSend.cy=player[tempIndex].cy;
					  send.push_back(tempSend);
					  m_maxCard = m_double[i].max;
					  }
					  }
				   m_sendArray.cardNum=2;
				  m_sendArray.type=BOTHCARDS;
				  deletePlayer(player,send,ID);
				  return true;
				  }
			  }
				}
			break;
		case THREECARDS:
			if (!m_three.empty())//单张数组不等于空
				{
				for (int i=0;i<m_three.size();i++)
			  {
			  if (m_three[i].m_ISprimary==true&&m_three[i].max>m_sendArray.max)
				  {
				  for (int j=m_three[i].min;j<=m_three[i].max;j++)
					  {
					  for (int k=0;k<=2;k++)
						  {
						  tempIndex= returnIndex(player,j);
						  tempSend.coord_x=x+k*20-30*Customunsigned;
						  tempSend.coord_y=y;
						  tempSend.ID=ID;
						  tempSend.cx=player[tempIndex].cx;
						  tempSend.cy=player[tempIndex].cy;
						  send.push_back(tempSend);
						  m_maxCard = m_three[i].max;
						  }
					  }
				   m_sendArray.cardNum=3;
				  m_sendArray.type =THREECARDS;
				  deletePlayer(player,send,ID);
				  return true;
				  }
			  }
				}
			break;
		case THREECARDSOFONE:
			if (!m_three.empty())//单张数组不等于空
				{
				for (int i=0;i<m_three.size();i++)
			  {
			  if (m_three[i].m_ISprimary==true&&m_three[i].max>m_sendArray.max)
				  {
				  
					  for (int k=0;k<=2;k++)
						  {
						  tempIndex= returnIndex(player,m_three[i].max);
						  tempSend.coord_x=x+k*20-60*Customunsigned;
						  tempSend.coord_y=y;
						  tempSend.ID=ID;
						  tempSend.cx=player[tempIndex].cx;
						  tempSend.cy=player[tempIndex].cy;
						  send.push_back(tempSend);
						  m_maxCard = m_three[i].max;
						  }
					  
				  if (!m_single.empty())
					  {
					  for (int i=0;i<m_single.size();i++)
						  {
						  if (m_single[i].m_ISprimary)
							  {
							  tempIndex= returnIndex(player,m_single[i].max);
							  tempSend.coord_x=send[send.size()-1].coord_x+20;
							  tempSend.coord_y=y;
							  tempSend.ID=ID;
							  tempSend.cx=player[tempIndex].cx;
							  tempSend.cy=player[tempIndex].cy;
							  send.push_back(tempSend);
							   m_sendArray.cardNum=4;
							  m_sendArray.type=THREECARDSOFONE;
							  deletePlayer(player,send,ID);
							  return true;
							  }


						  }
					  }
				  }
					}for (vector<SENDCARDS>::iterator iter=send.begin();iter!=send.end();)
					{
					if (iter->ID==ID)
						{
						iter=send.erase(iter);
						}else
							iter ++;
						}

				return false;
				}
			break;
		case THREECARDSOFTWO:
			if (!m_three.empty())//单张数组不等于空
				{
				for (int i=0;i<m_three.size();i++)
			  {
			  if (m_three[i].m_ISprimary==true&&m_three[i].max>m_sendArray.max)
				  {
				  
					  for (int k=0;k<=2;k++)
						  {
						  tempIndex= returnIndex(player,m_three[i].max);
						  tempSend.coord_x=x+k*20-60*Customunsigned;
						  tempSend.coord_y=y;
						  tempSend.ID=ID;
						  tempSend.cx=player[tempIndex].cx;
						  tempSend.cy=player[tempIndex].cy;
						  send.push_back(tempSend);
						  m_maxCard = m_three[i].max;
						  }
					  
				  if (!m_double.empty())//单张数组不等于空
					  {
					  for (int i=0;i<m_double.size();i++)
						  {
						  if (m_double[i].m_ISprimary==true)
							  {
							  
								  for (int k=0;k<=1;k++)
									  {
									  tempIndex= returnIndex(player,m_double[i].max);
									  tempSend.coord_x=send[send.size()-1].coord_x+20;
									  tempSend.coord_y=y;
									  tempSend.ID=ID;
									  tempSend.cx=player[tempIndex].cx;
									  tempSend.cy=player[tempIndex].cy;
									  send.push_back(tempSend);
									  m_maxCard = m_double[i].max;
									  }
								  m_sendArray.type=THREECARDSOFTWO;
								   m_sendArray.cardNum=5;
							  deletePlayer(player,send,ID);
							  return true;
							  }
						  }
					  }
				  }
			  }
				for (vector<SENDCARDS>::iterator iter=send.begin();iter!=send.end();)
					{
					if (iter->ID==ID)
						{
						iter=send.erase(iter);
						}else
							iter ++;
					}
				
				return false;
				}
			break;
		case LINKCARDS:
			if (!m_link.empty())
			{
			 for (int i=0;i<m_link.size();i++)
			 {
			  if (m_link[i].m_ISprimary==true&&((m_link[i].max>m_sendArray.max&&(m_link[i].max-m_link[i].min==m_send.size()-1))||m_noSendNum==2))
			  { 
			    for (int j=m_link[i].min,index=0;j<=m_link[i].max;j++,index++)
			    {
				tempIndex= returnIndex(player,j);
				tempSend.coord_x=x+index*20-(m_link[i].max-m_link[i].min)*20*Customunsigned;
				tempSend.coord_y=y;
				tempSend.ID=ID;
				tempSend.cx=player[tempIndex].cx;
				tempSend.cy=player[tempIndex].cy;
				send.push_back(tempSend);
				m_maxCard = m_link[i].max;
			    }
				 m_sendArray.cardNum=m_link[i].max-m_link[i].min+1;
				m_sendArray.type=LINKCARDS;
				deletePlayer(player,send,ID);
				 return true;
			  }
			 }
			}
			break;
		case LINKBOTHCARDS:
			if (!m_doubleLink.empty())
			{
			for (int i=0;i<m_doubleLink.size();i++)
			{
			 if (((m_doubleLink[i].m_ISprimary==true)
				 &&(m_doubleLink[i].max>m_sendArray.max
				 &&(m_doubleLink[i].max-m_doubleLink[i].min==m_send.size()/2-1))||m_noSendNum==2))
			 {
			  //MessageBox(0,0,0,0);
			   for (int j=m_doubleLink[i].min,index=0;j<=m_doubleLink[i].max;j+=1,index+=1)
			   {
			     for (int k=0;k<=1;k++)
			     {
				 tempIndex= returnIndex(player,j);
				 tempSend.coord_x=x+index*40+k*20-100*Customunsigned;
				 tempSend.coord_y=y;
				 tempSend.ID=ID;
				 tempSend.cx=player[tempIndex].cx;
				 tempSend.cy=player[tempIndex].cy;
				 send.push_back(tempSend);
				 m_maxCard = m_double[i].max;
				   
			     }
			   }
			   m_sendArray.cardNum=(m_doubleLink[i].max-m_doubleLink[i].min+1)*2;
			   	m_sendArray.type=LINKBOTHCARDS;
			   deletePlayer(player,send,ID);
			   return true;
			 }
			}
			}
			break;
		case PLANECARDS:	
			return  sendPlane(player,send,ID,x,y);
			break;
		case PLANECARDSOFONE:
		
			
				if (m_handNum[0].s_single.size()>=2&&sendPlane(player,send,ID,x-60,y))
				 {
				 for (int i=0;i<2;i++)
				  {
				  tempIndex= returnIndex(player,m_handNum[0].s_single[i].max);
				  tempSend.coord_x=send[send.size()-1].coord_x+20;
				  tempSend.coord_y=y;
				  tempSend.ID=ID;
				  tempSend.cx=player[tempIndex].cx;
				  tempSend.cy=player[tempIndex].cy;
				  send.push_back(tempSend);
				  }
				 m_sendArray.cardNum=8;
				 m_sendArray.type=PLANECARDSOFONE;
				 deletePlayer(player,send,ID);
				 return true;
				 }

				 if (m_handNum[0].s_double.size()>=1&&sendPlane(player,send,ID,x-60,y))
				 {
				  for (int i=0;i<=1;i++)
				  {
				  tempIndex= returnIndex(player,m_handNum[0].s_double[0].max);
				  tempSend.coord_x=send[send.size()-1].coord_x+20;
				  tempSend.coord_y=y;
				  tempSend.ID=ID;
				  tempSend.cx=player[tempIndex].cx;
				  tempSend.cy=player[tempIndex].cy;
				  send.push_back(tempSend);
				  }
				   m_sendArray.cardNum=8;
				   m_sendArray.type=PLANECARDSOFONE;
				  deletePlayer(player,send,ID);
				  return true;
				   
				 if (m_handNum[0].s_three.size()>=1&&sendPlane(player,send,ID,x-60,y))
					 {
					 for (int i=0;i<=1;i++)
						 {
						 tempIndex= returnIndex(player,m_handNum[0].s_three[0].max);
						 tempSend.coord_x=send[send.size()-1].coord_x+20;
						 tempSend.coord_y=y;
						 tempSend.ID=ID;
						 tempSend.cx=player[tempIndex].cx;
						 tempSend.cy=player[tempIndex].cy;
						 send.push_back(tempSend);
						 }
					  m_sendArray.cardNum=8;
					  m_sendArray.type=PLANECARDSOFONE;
					 deletePlayer(player,send,ID);
					 return true;

					 }
				}
			
			break;
		case PLANECARDSOFTWO:
			
			if (m_handNum[0].s_double.size()>=2&&sendPlane(player,send,ID,x-90,y))
				{
				for (int i=0;i<m_card.second;i++)
					{
					for (int j=0;j<=1;j++)
					{
					tempIndex= returnIndex(player,m_handNum[0].s_double[i].max);
					tempSend.coord_x=send[send.size()-1].coord_x+20;
					tempSend.coord_y=y;
					tempSend.ID=ID;
					tempSend.cx=player[tempIndex].cx;
					tempSend.cy=player[tempIndex].cy;
					send.push_back(tempSend);
					}
					
					}
				 m_sendArray.cardNum=10;
				 m_sendArray.type=PLANECARDSOFTWO;
				deletePlayer(player,send,ID);
				return true;
				}
			/*for (vector<SENDCARDS>::iterator iter=send.begin();iter!=send.end();)
				{
				if (iter->ID==ID)
					{
					iter=send.erase(iter);
					}else iter++;
				}*/
			
			break;
		case BOMBCARDSOFONE:
			if (!m_bomb.empty())
			{
				for (int j=0;j<4;j++)
					{
					tempIndex= returnIndex(player,m_bomb[0].max);
					tempSend.coord_x=x+20*j-Customunsigned*90;
					tempSend.coord_y=y;
					tempSend.ID=ID;
					tempSend.cx=player[tempIndex].cx;
					tempSend.cy=player[tempIndex].cy;
					send.push_back(tempSend);
					}

				if (m_handNum[0].s_single.size()>=2)
				 {
				 for (int i=0;i<2;i++)
				  {
				  tempIndex= returnIndex(player,m_handNum[0].s_single[i].max);
				  tempSend.coord_x=send[send.size()-1].coord_x+20;
				  tempSend.coord_y=y;
				  tempSend.ID=ID;
				  tempSend.cx=player[tempIndex].cx;
				  tempSend.cy=player[tempIndex].cy;
				  send.push_back(tempSend);
				  }
				 m_sendArray.cardNum=5;
				 m_sendArray.type=BOMBCARDSOFONE;
				 deletePlayer(player,send,ID);
				 return true;
				 }

				if (m_handNum[0].s_double.size()>=1)
				 {
				 for (int i=0;i<=1;i++)
				  {
				  tempIndex= returnIndex(player,m_handNum[0].s_double[0].max);
				  tempSend.coord_x=send[send.size()-1].coord_x+20;
				  tempSend.coord_y=y;
				  tempSend.ID=ID;
				  tempSend.cx=player[tempIndex].cx;
				  tempSend.cy=player[tempIndex].cy;
				  send.push_back(tempSend);
				  }
				 m_sendArray.cardNum=5;
				  m_sendArray.type=BOMBCARDSOFONE;
				 deletePlayer(player,send,ID);
				 return true;

				 }

				}


			break;

		case BOMBCARDSOFTWO:
			if (!m_bomb.empty())
				{
				for (int j=0;j<4;j++)
					{
					tempIndex= returnIndex(player,m_bomb[0].max);
					tempSend.coord_x=x+20*j-Customunsigned*135;
					tempSend.coord_y=y;
					tempSend.ID=ID;
					tempSend.cx=player[tempIndex].cx;
					tempSend.cy=player[tempIndex].cy;
					send.push_back(tempSend);
					}
				if (m_handNum[0].s_double.size()>=2)
				 {
				 for (int i=0;i<=1;i++)
				  {
				  for (int j=0;j<=1;j++)
				  {
				  tempIndex= returnIndex(player,m_handNum[0].s_double[i].max);
				  tempSend.coord_x=send[send.size()-1].coord_x+20;
				  tempSend.coord_y=y;
				  tempSend.ID=ID;
				  tempSend.cx=player[tempIndex].cx;
				  tempSend.cy=player[tempIndex].cy;
				  send.push_back(tempSend);
				  }
				
				  }
				 m_sendArray.cardNum=6;
				  m_sendArray.type=BOMBCARDSOFTWO;
				 deletePlayer(player,send,ID);
				 return true;

				 }
				}

			break;
		}	            
	  return false;
	}