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


C++ Neighbors::clear方法代码示例

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


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

示例1: main

int main()
{
    Nodes nodes;
    Neighbors neighbors;

    int n = 0, edges = 0, index = 0, nodeX = 0, nodeY = 0;

    while (true)
    {
        cin >> n;

        if (!n)
        {
            break;
        }

        nodes.clear();
        neighbors.clear();

        for (index = 0; index < n; index++)
        {
            nodes[index] = Uncolored;
        }
        
        cin >> edges;

        while (edges)
        {
            cin >> nodeX >> nodeY;

            neighbors[nodeX].push_back(nodeY);
            neighbors[nodeY].push_back(nodeX);

            edges--;
        }

        cout << (Colorable(nodes, neighbors)? "BICOLORABLE." : "NOT BICOLORABLE.") << endl;
    }
    return 0;
}
开发者ID:skalyanasundaram,项目名称:BrainTuners,代码行数:40,代码来源:10004-BiColoring.cpp

示例2: main

int main(int argc, char *argv[]) {


  std::string input;
  int width;
  int height;
  int row = 0;
  int attempt = 0;

  while(std::getline(std::cin, input)) {
    char c = input.at(0);
    if(c == '.' || c == 'X' || c == '*') {
      ++row;
      neighbors.clear();
      for(int pos = 0; pos < (int) input.length(); ++pos) {
        VertexWeight vertexWeight;
        vertexWeight.first = pos;
        char temp = input.at(pos);
        if(temp == '.') {
          vertexWeight.second = 1;
        } else if(temp == '*') {
          vertexWeight.second = 2;
        } else {
          vertexWeight.second = 3;
        }
        neighbors.push_back(vertexWeight);
      }
      adjList.push_back(neighbors);
      if(height == row) {
        visited.clear();
        for(int index = 0; index < height; ++index) {
          visited.push_back(std::vector<bool>(width, false));
        }
        for(int i = 0; i < height; ++i) {
          for(int j = 0; j < width; ++j) {
            if((visited[i])[j] == false && ((adjList[i])[j]).second != 1) {
              area = 0;
              floodFill(i, j, ((adjList[i])[j]).second);
              if(area)
              areas.push_back(area);
            }
          }
        }

        std::cout << "Throw " << ++attempt << std::endl;
        std::sort(areas.begin(), areas.end());
        int numAreas = (int)areas.size() - 1;
        for(std::vector<int>::iterator it = areas.begin(); it != areas.end(); ++it) {
          std::cout << *it;
          if(numAreas--) {
            std::cout << " ";
          }
        }
        std::cout << std::endl;
        std::cout << std::endl;
      }
    } else {
      row = 0;

      std::stringstream sbuf;
      sbuf << input;
      sbuf >> width >> height;

      adjList.clear();
      areas.clear();

      if(width == 0 && height == 0) {
        break;
      }
    }
  }
  return 0;
}
开发者ID:chaitanyav,项目名称:UVA,代码行数:73,代码来源:657_the_die_is_cast.cpp


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