# 查看数组中的元素是否存在连续3次相同的元素！

0

0

```var arr = [3, 2, 8, 9, 22, 7, 7, 7, 8, 6];
var counter = 1,value;
for(var i=0; i< arr.length;i ++){
if(value !== arr[i]){
coutner = 1;
}else{
counter += 1;
}
value = arr[i];
if(counter === 3){
break;
}
}

//value的值就是首次重现三次的元素。```

0

```size_t lis(const int src[], size_t sz,int count)
{
if (src==NULL || sz<1) return 0;
vector<int> min_v(sz);
min_v[0]=src[0];
size_t i,len=1;
int value;
for (i=1; i<sz; ++i) {
value=src[i];
if (value=min_v[len-1]) min_v[len++]=value;
else *lower_bound(&min_v[0],&min_v[len], value)=value;
//if(len==count)
{
//你的操作
}
}
return len;
}```

0
``` int[] array = new int[] { 1, 2, 3, 3, 3, 4, 5, 5, 5, 6 };
var list = new List<int>();

int count = 0;
for (int i = 0; i < array.Length; i++)
{
if (i != 0)
{
if (array[i - 1] == array[i])
{
count++;
if (count == 2)
{
count = 0;
}
}
}
}```

Zery | 园豆：6139 (大侠五级) | 2015-11-02 16:09

0
```int[] arr = new int[] { 1, 2, 3, 4, 5, 6, 6, 7, 7, 7, 8, 9 };
var repeatNum = 3;
for (var i = repeatNum - 1; i < arr.Length; i++)
{
if (arr[i - 2] == arr[i - 1] && arr[i - 1] == arr[i])
{
Console.WriteLine(i+":"+arr[i]);
break;
}
}