本文整理汇总了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;
}
示例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;
}