#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e4;
typedef struct SqList
{
int data[MAX_N];
int length;
} SqList;
void deleteRepeat(SqList &L)
{
int k = 0;
for (int i = 0; i < L.length; i++)
{
if (i == 0 || L.data[i] != L.data[i - 1])
{
L.data[k] = L.data[i];
++k;
}
}
L.length = k;
}
int main()
{
SqList L;
L.data[0] = 1;
L.data[1] = 2;
L.data[2] = 3;
L.data[3] = 3;
L.data[4] = 7;
L.data[5] = 7;
L.data[6] = 7;
L.data[7] = 7;
L.data[8] = 8;
L.data[9] = 10;
L.length = 10;
cout << "begin: ";
for (int i = 0; i < L.length; i++)
{
cout << L.data[i] << " ";
}
deleteRepeat(L);
cout << "\nafter: ";
for (int i = 0; i < L.length; i++)
{
cout << L.data[i] << " ";
}
return 0;
}
09-14
07-15
439
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)