(搜索应用)Oil Deposits( UVA - 572 )

Oil Deposits UVA - 572

#include 
#include
#include
#include
#include
using namespace std;
char a[100][100];
int vis[100][100];
int dx[8]= {0,1,1,1,0,-1,-1,-1};
int dy[8]= {1,1,0,-1,-1,-1,0,1};
typedef struct QNode
{
    int len;
    int data;
    int data1;
    struct QNode *next;
} QNode,*QueuePtr;
typedef struct
{
    QueuePtr front1;
    QueuePtr rear;
} LinkQueue;
int m,n;
void initQueue(LinkQueue &Q)
{
    Q.front1=Q.rear=(QueuePtr)malloc(sizeof(QNode));
    Q.front1->next=NULL;
    Q.rear->len=0;
}
void EnQueue(LinkQueue &Q,int e,int e1)
{
    QNode *p;
    p=(QueuePtr)malloc(sizeof(QNode));
    p->data=e;
    p->data1=e1;
    p->next=NULL;
    Q.rear->next=p;
    Q.rear=p;
    Q.rear->len++;
}
QueuePtr dequeue(LinkQueue &Q)
{
    QNode *p;
    p=Q.front1->next;
    Q.front1->next=p->next;
    if(Q.rear==p)
    {
        Q.rear=Q.front1;
    }
    free(p);
    Q.rear->len--;
    if(Q.rear!=Q.front1)
        return Q.front1->next;
}
int emptyqueue(LinkQueue &Q)
{
    if(Q.rear==Q.front1)
        return 1;
    return 0;
}
int bfs()
{
    int x,y;
    LinkQueue Q;
    initQueue(Q);
    int num=0;
    for(int i1=0; i1=0&&mx=0&&mydata;
                    y=q->data1;
                }
            }
        }
    return num;
}
int main()
{
  //  freopen("C:\\Users\\Administrator\\Desktop\\ceshi.txt","r",stdin);
    while(~scanf("%d%d",&m,&n))
    {
        int k1=0,k2=0;
        if(m==0)
            break;
        memset(vis,0,sizeof(vis));
        for(int i=0; i>a[i][j];
                if(a[i][j]=='*')
                {
                    vis[i][j]=1;
                }
            }
        cout<

你可能感兴趣的:(算法,数据结构)