array removal doubt

I have a basic question i.e i have an integer array with numbers from 1 to n.... Whenever i get a value called no,i should delete the element in the array at this position(no)... And push the other numbers after this deleted number before by one... Can you write a code snippet for me....?
NO. Do your own homework.

This is not an homework.. i tried it but its giving wrong output...
Try something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	int arr[] = {1,2,3,4,5,6,7,8,9,0};

	cout << "Before: ";
	for (int i = 0; i < (sizeof(arr)/sizeof(int)); i++)
		cout << arr[i] << " ";
	cout << endl;

	// doing magic here
	memcpy(arr+4, arr+5, sizeof(arr) - sizeof(int)*5);

	cout << "After: ";
	for (int i = 0; i < (sizeof(arr)/sizeof(int)); i++)
		cout << arr[i] << " ";
	cout << endl;
}
Before: 1 2 3 4 5 6 7 8 9 0
After: 1 2 3 4 6 7 8 9 0 0




Helps? 0 marks here like in a c-string simply an end of content.

Maikel


And please do not multipost in forums just because you do not get a satisfying answer. If its no homework its not urgent, is it?
Last edited on
LIAR. This is a basic homework question, taught in CS 101 or earlier. And you blatently ask we do such an easy thing for you! Why would anyone trust you to write software?

@maikel
Do you really think that it is useful to giving a solution pretty-packaged for someone who won't even bother to try? Can you give me $100?


More and more I really am considering going the way of Grey Wolf. This is absurd.
Don't leave us duoas, the n00b storm will subside eventually. t-t
closed account (z05DSL3A)
gajji2020 wrote:
This is not an homework.. i tried it but its giving wrong output...

Gajji, If you had posted your code showing that you had made an attempt but failed, then you may have got a better response to your question. If it is homework, an exercise from a book, or something you need to do yourself, makes little difference; just show that you are not after a free meal.

How To: Ask Questions The Smart Way
http://www.cplusplus.com/articles/how_to_ask/
Topic archived. No new replies allowed.