魔术师发牌问题C++实现

 #include"CirList.h"
#include
using namespace std;
int main()
{
 CirListpoker;
 for(int i=0;i<13;i++)
 {//创建循环链表,存储13张牌
  poker.AddTail(0);
 
 }
 poker.SetBegin();
 poker.GetNextNode();
 for(int i=1;i<14;i++)
 {
  poker.SetData(i);
  for(int j=0;j<=i;j++)
  {
   poker.GetNextNode();//寻找插入位置
   if(poker.GetCur()->GetData()!=0)
   {//当前位置已有牌,顺序查找下一个位置
    j--;
   }
   if(j==13)
    break;
  }
 }
 poker.SetBegin();
 poker.GetNextNode();
 for(int i=0;i<13;i++)
 {
  cout<GetData()<<"*";
  poker.GetNextNode();

 }
 cout<  return 0;


}


 参见:http://www.oschina.net/code/snippet_181847_9173

你可能感兴趣的:(魔术师发牌问题C++实现)