Help Arrays!

I need to make a program that will delete one element from array and shift to the left... Am not that good at english i hope you understand.

This is what i have done.. please help. its writen on my language, if someone can help you can write it on english. thx guys!
[code]

#include <iostream>
#include <cstdlib>


using namespace std;
int main()


{
int n;
cout << "Unesite velicinu niza : \n";
cin >> n;
cout << endl << endl;
int x[n];
cout << "Unesite brojeve :\n" << endl;
for (int i = 0;i < n; i++)
{

cout << "x["<<i<<"]-- >";
cin >> x[i];

}cout << endl;
cout << "Unesite broj koji zelite da obrisete : \n";
int a;
a = n;
cin >> a;
for (int i = 0;i < a; i++)
{


a[x] = a[x+1];
a[x-1] = 0;
cout << x[n] << endl;
cout << endl;
}



system ("PAUSE");
return 0;
Last edited on
This int x[n]; is not valid [c]/c++. Change it to int *x = new int[n]; und delete[] it at the end.

If you want to enter the position to delete:
1
2
3
4
5
6
7
8
for (int i = a;i < n; i++) // assuming a = 1 -> 0 in the array
{


x[i-1] = x[i];
cout << x[i] << endl;
cout << endl;
}
Thanx "coder777". Your are the best!
I finished the program..
Topic archived. No new replies allowed.