Deleting duplicates from an array

Im pretty much new to C++ and trying to write a program for class that asks a user input for an array, ends with a sentinel, and deletes duplicate integers, i can get the integers to list but cant figure out the function to delete duplicates and repost the list, can anyone help me?

here is my current program, dont laugh if its completely wrong:

#include <iostream>
using namespace std;

const int SIZE=20;
const double SENTINEL = -99.0;

int main()
{
int list[SIZE];
int n;
int i = 0;
int actSize;

cout << "Please enter in a series of numbers, '-99.0' to end " << endl;
for (i = 0; i < SIZE && i != SENTINEL; i++)
cin >> n;

if (list[i] == SENTINEL) {
actSize= i - 1;
}else{
actSize = SIZE;
}
cout << list[0] << " ";
for (int i = 0; i < actSize; i++)
{
bool matching = false;
for (int j = 0; (j<i) && (matching == false); j++)

if (list[i] == list[j]) matching = true;
cout << list[i] << " ";

}}
Ill code tag it for you

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;

const int SIZE=20;
const double SENTINEL = -99.0;

int main()
{
int list[SIZE];
int n;
int i = 0;
int actSize;

cout << "Please enter in a series of numbers, '-99.0' to end " << endl;
for (i = 0; i < SIZE && i != SENTINEL; i++)
cin >> n;

if (list[i] == SENTINEL) {
actSize= i - 1;
}else{
actSize = SIZE;
}
cout << list[0] << " ";
for (int i = 0; i < actSize; i++)
{
bool matching = false;
for (int j = 0; (j<i) && (matching == false); j++)

if (list[i] == list[j]) matching = true;
cout << list[i] << " ";

}}
closed account (zb0S216C)
and deletes duplicate integers

The amount of elements in standard arrays are fixed, therefore, the element count cannot be changed.
Topic archived. No new replies allowed.