注册 登录
编程论坛 数据结构与算法

广度优先遍历算法有关队列问题

丘汤媚 发布于 2014-12-26 21:19, 1206 次点击
while(!s.IsEmpty())
    {
        k=0;
        s.DeQueue(loc);
        while(k<vmax)
        {
            cout<<++n<<endl;
            if(edge[loc][k]==1&&visited[k]==0)   
            {
                cout<<vl[k]<<' ';
                visited[k]=1;
                s.EnQueue(k);   
            }
            k++;
        }
    }

template <class T>
bool LinkedQueue<T>::DeQueue(T& x)
{
    if(IsEmpty()==true) return false;
    QNode<T> *p=front;
    x=p->data;                  //断点测试时到这里就不行了
    front=front->next;delete p;
    cout<<'y';
    return true;
}

Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\kernel32.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\KernelBase.dll', no matching symbolic information found.
First-chance exception in 数据结构_图.exe: 0xC0000005: Access Violation.
The program 'F:\数据结构\数据结构_图\Debug\数据结构_图.exe' has exited with code 0 (0x0).

第二遍循环的时候DeQueue()就不能调用了,请问该怎么解决。
0 回复
1