去掉有序数组中的重复元素:

int RemoveDuplates(int A[], int nCnt)
{
int nNewLen = ;
int j = ; for (int i = , j = ; i < nCnt && j < nCnt; i++)
{
while(j < nCnt && A[i] == A[j])
j++; if( j > i + && j < nCnt)
A[i + ] = A[j]; nNewLen++;
} return nNewLen;
}
05-07 15:41