```
int count=n,j=0;
for(int i=0;i<n;i++)
{
while(A[i]==elem)
{
count--;
i++;
}
if(i==n)
break;
A[j++]=A[i];
}
return count;
```

When I rewrite it this way,I got AC! But I think the old one is right.

```
int j=0;
for(int i=0;i<n;i++)
{
if(A[i]!=elem)
A[j++]=A[i];
}
return j;
```