请教高手 详细解释
#include <stdio.h>#define N 20
fun(int *a, int n, int x)
{
int p = 0, i;
a[n] = x;
while (x != a[p])
p = p+1;
if (p == n)
{
return -1;
}
else
{
/********found********/
for (i=p; i<n; i++)
a[i+1] = a[i];
return n-1;
}
}
main()
{
int w[N] = {-3, 0, 1, 5, 7, 99, 10, 15, 30, 90}, x, n, i;
n = 10;
printf("The original data:\n");
for (i=0; i<n; i++)
printf("%5d", w[i]);
printf("\nInput x (to delete):");
scanf("%d", &x);
printf("Delete :%d\n", x);
n = fun(w, n, x);
if (n == -1)
{
printf("***Not be found!***\n\n");
}
else
{
printf("The data after delete :\n");
for (i=0; i<n; i++)
printf("%5d", w[i]);
printf("\n\n");
}
}