怎么对一个二维数组做遍历,找出里面连续的相同元素
RT
比如现有如下数组
int s_color[8][8] = {
34, 92, 26, 34, 93, 10, 34, 39,
10, 10, 10, 10, 15, 15, 39, 93,
15, 26, 26, 93, 93, 39, 10, 15,
26, 34, 39, 15, 39, 34, 34, 26,
34, 39, 39, 34, 52, 26, 10, 10,
26, 34, 10, 15, 52, 52, 15, 39,
93, 15, 26, 26, 15, 39, 93, 93,
34, 52, 93, 10, 93, 10, 39, 26
};
for(i=0;i<n*n-1;i++)
{
for(j=i;i<n*n;j++)
if(s_color[i/n][i%n]!=s_color[j/n][j%n])
break;
if(j!=i+1)
for(k=i;k<j;k++)
printf("%d ",a[k/n][k%n]);
}