编译时错误.L值必需c ++

时间:2014-08-13 14:48:16

标签: c++

此代码显示编译时错误

#include<stdio.h>
#include<conio.h>
#define SIZE 7
int a[SIZE][SIZE],q[SIZE*SIZE],visited[SIZE][SIZE],n,i,j,f=0,r=-1;
int parent[SIZE*SIZE], x_dest, y_dest, x_temp, y_temp;
int flag =0;
void find_neighbours(int x, int y)
{
    if (( ((y+1)=0) && (a[x][y-1])) && (visited[x][y-1]))
    {
        q[++r]= x*n + (y-1);
        parent[x*n + (y-1)] = x*n +y;
        visited[x][y-1] =1;
    }
    if ((x+1)=0 && (a[x-1][y]) && !visited[x-1][y])
    {
        q[++r]=(x-1)*n+(y);
        parent[(x-1)*n+(y)]=x*n+y;
        visited[x-1][y]=1;
    }
}
void bfs(int x, int y)
{
    find_neighbours(x, y);
    if(f<=r)
    {
        x_temp = q[f]/n;
        y_temp = q[f] - n*x_temp;
        if (x_temp == x_dest && y_temp == y_dest)
        {
            flag =1;
            return ;
        }
//visited[x_temp][y_temp] = 1;
        f++;
        bfs(x_temp,y_temp);
    }
}
int main()
{
    int x,y,val;
    int source_x , source_y;
    n = SIZE;
    for(i=0;i< n;i++)
    {
        q[i]=0;
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            visited[i][j] = 0;
        }
    }
    for(i=0;i<n*n;i++)
    parent[i] = 0;
    printf("n Enter graph data in matrix form:n");
    for(i=0;i< n;i++)
    for(j=0;j<n;j++)
    scanf("%d",&a[i][j]);
    source_x = 0;
    source_y = 0;
    visited[source_x][source_y] =1;
    x_dest = 6;
    y_dest = 6;
    bfs(0,0);
    if (!flag)
    {
        printf("not reachable \n");
        return 0;
    }
    x = x_temp;
    y = y_temp;
    while(x!=0 || y!=0)
    {
        val = parent[x *n + y];
        x = val/n;
        y = val - x*n;
        printf("%d %dn ", x,y);
    }
    return 0;
}

1 个答案:

答案 0 :(得分:2)

你到处都有这样的代码:

if ((x+1)=0)

x+1不是lvalue,而是您尝试分配给它。

大概你的意思是==

顺便说一句,您的代码通常很难阅读。什么阻止你写文档评论和使用有意义的变量名?