思路很简单,两个下标指针
<span style="font-family:Microsoft YaHei;font-size:14px;">int removeElement(int A[], int n, int elem) {
int i,j;
for(i = 0,j = 0; i < n; i++){
if(A[i] != elem)
A[j++] = A[i];
}
return j;
}</span>
思路很简单,两个下标指针
<span style="font-family:Microsoft YaHei;font-size:14px;">int removeElement(int A[], int n, int elem) {
int i,j;
for(i = 0,j = 0; i < n; i++){
if(A[i] != elem)
A[j++] = A[i];
}
return j;
}</span>