delete repeats..

pls help me i making a simple program that deletes duplicates.. just a simple program pls..example:input:1 2 2 4 3 3 2 4 5 output: 1 2 4 3 5pls help me deal with this.. im really new to proramming..

this is what ive done..
#include <iostream.h>
#include <conio.h>


int removedup (int inpArray[], int inpArraySize, int outArray[], int arr[]);
int main()
{
int size=5;
int inpArray[size], inpArraySize, outArray[size], arr[size];
removedup(inpArray, inpArraySize, outArray, arr);
getchar();
return 0;
}
int removedup (int inpArray[], int inpArraySize, int outArray[], int arr[])
{
int j = 0;
int x, k, i;
int count = 0;
int flag, temp;
cout<<"Enter the size of inpArray\n";
cin>>inpArraySize;
for (x=0; x<inpArraySize; x++)
{
cin>>inpArray[x];
}
for(i = 1; (i <= inpArraySize) && flag; i++)
{
flag = 0;
for (j=0; j < (inpArraySize -1); j++)
{
if (inpArray[j+1] < inpArray[j])
{
temp = inpArray[j];
inpArray[j] = inpArray[j+1];
inpArray[j+1] = temp;
flag = 1;
}
}
}
cout<<"These are the original values of 'inpArray[] sorted from least to greatest\n";
for (x=0; x<inpArraySize; x++)
{
cout<<inpArray[x];
}
cout<<endl;
pcout<<"In addition, these are the values of the new array without duplicates\n";
for (x=0; x<inpArraySize; x++)
{
if (inpArray[x] != inpArray[x+1])
{
outArray[j]=inpArray[x];
j+=1;
}
}
j-=1;
for (i=0; i<inpArraySize-j; i++)
{
cout<<outArray[i]);
}
return 0;
}

whats my error??
Code tags.
And please, please stop using icky nonstandard conio.
Last edited on
Topic archived. No new replies allowed.