Beispiel #1
0
void bfs(Node **array, int sx, int sy, int maxx, int maxy){
    NodeQueue nodelist;
    nodelist.enqueue(&array[sx][sy]);
    array[sx][sy].if_source=1;
    array[sx][sy].if_watered=1;
    while (!nodelist.empty()){
        Node* temp=nodelist.top();
        select(temp->height, temp->x-1, temp->y, maxx, maxy, array, &nodelist);
        select(temp->height, temp->x+1, temp->y, maxx, maxy, array, &nodelist);
        select(temp->height, temp->x, temp->y-1, maxx, maxy, array, &nodelist);
        select(temp->height, temp->x, temp->y+1, maxx, maxy, array, &nodelist);
        nodelist.dequeue();
    }
}
Beispiel #2
0
int main()
{
        try
        {
        NodeQueue<int> Queue;
        Queue.enqueue(10);
        Queue.enqueue(20);
        Queue.enqueue(30);
        std::cout<<"Top is: "<<Queue.front()<<'\n';
        Queue.dequeue();
        Queue.print();
        }
        catch(const std::string& e)
        {
             std::cout<<e<<'\n';
        }
}