当前位置: 首页>>代码示例>>C++>>正文


C++ VPoint::push_back方法代码示例

本文整理汇总了C++中VPoint::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ VPoint::push_back方法的具体用法?C++ VPoint::push_back怎么用?C++ VPoint::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VPoint的用法示例。


在下文中一共展示了VPoint::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SearchAll

void SearchAll(string &word, string &occupy, int row, int col)
{
  int pos = row * size + col;
  occupy[pos] = OCCUPY;
  path.push_back(SPoint(row, col));
  word += tolower(board[pos]);
  if(!english.containsPrefix(word))
  {
    word = word.substr(0, word.size() - 1);
    occupy[pos] = EMPTY;
    path.pop_back();
    return;
  }
  if(word.size() >= 4 && InEnglish(word) && !InHumanWord(word))
  {
    recordWordForPlayer(word, COMPUTER);
    humanword.push_back(word);
    showpath();
  }

  //cout << word << ' ' << row << ' ' << col << endl;

  //Up
  if(row != 0 && occupy[pos - size] == EMPTY)
    SearchAll(word, occupy, row - 1, col);
  //Down
  if(row != size - 1 && occupy[pos + size] == EMPTY)
    SearchAll(word, occupy, row + 1, col);
  //Right
  if(col != size - 1 && occupy[pos + 1] == EMPTY)
    SearchAll(word, occupy, row, col + 1);
  //Left
  if(col != 0 && occupy[pos - 1] == EMPTY)
    SearchAll(word, occupy, row, col - 1);
  //UpRight
  if(row != 0 && col != size - 1 && occupy[pos - size + 1] == EMPTY)
    SearchAll(word, occupy, row - 1, col + 1);
  //UpLeft
  if(row != 0 && col != 0 && occupy[pos - size - 1] == EMPTY)
    SearchAll(word, occupy, row - 1, col - 1);
  //DownLeft
  if(row != size - 1 && col != 0 && occupy[pos + size - 1] == EMPTY)
    SearchAll(word, occupy, row + 1, col - 1);
  //DownRight
  if(row != size - 1 && col != size - 1 && occupy[pos + size + 1] == EMPTY)
    SearchAll(word, occupy, row + 1, col + 1);

  word = word.substr(0, word.size() - 1);
  path.pop_back();
  occupy[pos] = EMPTY;
}
开发者ID:wizardforcel,项目名称:se106labs,代码行数:51,代码来源:Boggle.cpp

示例2: RInBoard

bool RInBoard(const string &word, string &occupy, int row, int col, int index)
{
  //cout << word << ' ' << row << ' ' << col << ' ' << index << endl;
  
  int pos = row * size + col;
  occupy[pos] = OCCUPY;
  path.push_back(SPoint(row, col));
  if(tolower(word[index]) != tolower(board[pos]))
  {
    //cout << word[index] << ' ' << board[pos] << endl;
    occupy[pos] = EMPTY;
    path.pop_back();
    return false;
  }
  //cout << word << endl;
  if(index == word.size() - 1)
  {
    showpath();
    return true;
  }
  
  //Up
  if(row != 0 && occupy[pos - size] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row - 1, col, index + 1);
    if(res) return true;
  }
  //Down
  if(row != size - 1 && occupy[pos + size] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row + 1, col, index + 1);
    if(res) return true;
  }
  //Left
  if(col != 0 && occupy[pos - 1] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row, col - 1, index + 1);
    if(res) return true;
  }
  //Right
  if(col != size - 1 && occupy[pos + 1] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row, col + 1, index + 1);
    if(res) return true;
  }
  //UpRight
  if(row != 0 && col != size - 1 && occupy[pos - size + 1] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row - 1, col + 1, index + 1);
    if(res) return true;
  }
  //UpLeft
  if(row != 0 && col != 0 && occupy[pos - size - 1] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row - 1, col - 1, index + 1);
    if(res) return true;
  }
  //DownLeft
  if(row != size - 1 && col != 0 && occupy[pos + size - 1] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row + 1, col - 1, index + 1);
    if(res) return true;
  }
  //DownRight
  if(row != size - 1 && col != size - 1 && occupy[pos + size + 1] == EMPTY)
  {
    bool res = RInBoard(word, occupy, row + 1, col + 1, index + 1);
    if(res) return true;
  }

  occupy[pos] = EMPTY;
  path.pop_back();
  return false;  
}
开发者ID:wizardforcel,项目名称:se106labs,代码行数:74,代码来源:Boggle.cpp


注:本文中的VPoint::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。