What's the problem in output where the algorithm was correct ????
#include<iostream>
#include<stdio.h>
using namespace std;
main()
{
    int LA[100],K=1,N=5,L;//K=POSITION...N=element

    for(int i=0;i<=4;i++)
    {
        cin>>LA[i];
    }
     L=LA[K];
    for(int J=K ; J<N-1; J++)
    {
        LA[J]=LA[J+1];

    }
    cout<<"DELETE ITEM:";
    N=N-1;

    for(int P=0;P<=4;P++)
    {
        cout<<" "<<LA[P];
    }


}

the algorithm collect from Data structure book .

I am really guessing here because you don't tell us what you expected and what you got. But maybe you got no output -- if that is the case was it because you forgot to put a std::endl in your code e.g. add line 25 :

     cout<<endl;

The algorithm is a suffle down deletion, i.e if you have a set of number : 11 12 13 14 15, and you want to delete the number in the second position (12). you want to modify the array to be :

11 13 14 15

BUT not that because you have reduced the size of the array by one, the element in position 5 (i.e LA[4]) can be anything and it this case your output would have been

11 13 14 15 15

That is because in you code you wrote

for(int P=0;P<=4;P++)
  cout<<" "<<LA[P];

However better might have been:

for(int P=0;P<N;P++)
   cout<<" "<<LA[P];

If that doesn't cover the problem, tell us what you got and what you expected and we will try to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.