1

我是编程新手,我一直在尝试创建一个可以解决任何数独难题的程序。但是,我遇到了很多错误,在这个错误中,我无法弄清楚出了什么问题。

这是错误所在的代码:

for (short o = indice;o>=divergencias[n_diver];o--){
    N=historico[o];
    P=tabela[N];  //Line 205
    tabela[N]=0;  //Line 206
    }
    indice -= divergencias[n_diver];
    n_diver --;
    }

在标有注释的行上发生的错误是:

C:\(...)\main.cpp|205|error: invalid conversion from 'short unsigned int*' to 'short unsigned int'|

C:\(...)\main.cpp|206|error: incompatible types in assignment of 'int' to 'short unsigned int [9]'|

我一直在寻找这个错误,并没有找到任何令人满意的答案。此外,我学习编程知识的网站指定编写类似的东西b = billy [a+2];是有效的。所以我只是不明白这有什么问题......

4

1 回答 1

1

它看起来像tabela被声明为short unsigned tabela[9][9]. 为了从中获取类型项目,unsigned short您必须提供两个索引,而不是一个。

另一方面,如果您希望从 获取整个子数组tabela,则赋值左侧需要与 的一维数组兼容unsigned short,例如unsigned short*指针。

于 2012-08-05T22:23:53.550 回答