int RemoveElement(int A[], int n, int t)
{
int i = 0;
int j = n;
while(i<j)
{
if (A[i] == t)
{
while(--j > i && A[j] == t);
if(j <= i)
break;
else
A[i] = A[j];
}
++i;
}
return i;
}
#include <stdio.h>
void printArray(int A[], int n)
{
for (int i = 0; i < n; ++i)
printf("%c%d", i==0?'\n':',', A[i]);
}
int main(int argc, char** argv)
{
int A[] = {1,2,3,3,4,3,3,5,3,3,6,3,3,3,7,3,3,3,3,3,3};
printArray(A,21);
int n = RemoveElement(A,21,3);
printArray(A,n);
return 0;
}