October 20th, 2009, 12:23 AM
Hi everyone, I'm new and will probably be asking a lot of questions from here on out. I have an assignment where the user inputs 10 integers into an array, then the program is supposed to output the numbers, but no duplicates. (ex. INPUT: 1 2 2 3 1 10 6 4 6 20 OUTPUT: 1 2 3 10 6 4 20)
What I'm having trouble with is figuring out the algorithm needed to not cout the duplicates.
Here's what I have...
And that's where I'm at. We are also not allowed to sort the array. I wanted to try something like
using namespace std;
cout << "Enter 10 numbers...\n";
for(int i=0; i<10;i++)
cin >> num[i];
but since it isn't sorted, it will not check any previous numbers in the array, only the one next to it...
for(int j=0; j<10;j++)
if(num[n] != num[n+1]
cout << num[i]
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!