int locate_color( const uint8_t array[],
unsigned int cols,
unsigned int rows,
uint8_t color,
unsigned int *x,
unsigned int *y )
{
for (int z = 0; z < rows; z++)
{
for (int c = 0; c < cols; c++)
{
if (array[z] == color)
{
*x = color;
}
if (array[c] == color)
{
*y = color;
}
return 1;
}
return 0;
}
此函数是从数组中定位颜色的函数。它从左到右,从上到下搜索,找到后将坐标存储到*x和*y中。但是当我运行代码时,它给了我一个错误。谁能告诉我我哪里出错了?