Arrrays

Does anybody knows how to store 10 elements in an array and delete the duplicate terms ? ( its a single dimension array )
Last edited on
look into <algorithm>
@OP
Do you mean delete consecutive duplicate terms or duplicate terms anywhere in the array?

For the former case you can use std::unique in the algorithm header.

For the latter, you will either have to first sort the array using std::sort and then use std::unique or develop an algorithm of your own.
oh ok thanks,actually i meant if we taking both the cases where the inputted duplicate terms can be consecutive as well as in random order and then it can be printed without the duplicate numbers.
can you send the algorithm if possible ?
actually i meant if we taking both the cases where the inputted duplicate terms can be consecutive as well as in random order


That is the second case which refers to "duplicate terms anywhere in the array." Note that anywhere includes the possibility of "next to" or "consecutive."

How would you do it on paper?
Topic archived. No new replies allowed.