题目:有 N 队进行循环赛,用程序排出赛程表
#include <vector>
#include <stack>
#include <algorithm>
#include "time.h"
struct _ComNode //比赛节点
{
int m_nHost; //主场
int m_nGuest; //客场
};
typedef std::vector<_ComNode *> _ComList; //比赛列表
typedef std::vector<_ComNode *> _Row; //一行数据
typedef std::stack<_Row *> _ResultStack; //结果列表
typedef _ComList::iterator _ComListItor;
typedef _Row::iterator _RowItor;
typedef std::vector<int> _TemList;
_ComList g_ComList;
_ComList g_ComTemList;
_ResultStack g_ResultStack; //结果栈
_TemList g_TemList;
int g_nNum = 14;
int g_nRandPos = 0;
void IniComList()
{
for( int i=0; i<g_nNum; ++i )
{
for( int j=0; j<g_nNum; ++j )
{
if( i != j )
{
_ComNode *pNode = new _ComNode;
pNode->m_nHost = i;
pNode->m_nGuest = j;
g_ComList.push_back( pNode );
}
}
}