Implement the function to insert, delete, and query array elements.
# Include
# Deprecision MAX 100
Int insert (int a [], int n, int I, int x)
{
Int j;
If (n + 1> MAX)
Printf (no inserted space); // Arrays can only store MAX count
Else if (I <1 | I> n + 1)
Printf (the inserted position is invalid); // The inserted position ranges from 1 .. n + 1.
Else
{
For (j = n-1; j> I-2; j --)
A [j + 1] = a [j]; // move the I position in the array and the number next to it to one cell.
A [I-1] = x; // insert x at the I position
N ++;
}
Return n; // return the current array size
}
Int del (int a [], int n, int I)
{
Int j;
If (I <1 | I> n)
Printf (the deletion location is invalid );
Else
{
For (j = I-1; j A [j] = a [j + 1];
N --;
}
Return n;
}
Int search (int a [], int n, int x)
{
Int I;
For (I = 0; I {
If (a [I] = x)
Return I + 1;
}
Return-1;
}
Void printArray (int a [], int n)
{
Int I;
For (I = 0; I ++)
{
If (I = N-1)
{
Printf (% d, a [I]);
Break;
}
Printf (% d, a [I]);
}
}
Void main ()
{
Int n, I, a [MAX];
Int index, x;
Printf (number of elements in the input array );
Scanf (% d, & n );
For (I = 0; I Scanf (% d, & a [I]);
Printf (enter the location and number of inserts );
Scanf (% d, & index, & x );
N = insert (a, n, index, x );
PrintArray (a, n );
Printf (enter the location of the element to be deleted );
Scanf (% d, & index );
N = del (a, n, index );
PrintArray (a, n );
Printf (enter the element to be queried );
Scanf (% d, & x );
I = search (a, n, x );
If (I! =-1)
Printf (% d location: % d, x, I );
Else
Printf (% d, x not found );
}