Quote Originally Posted by viperlasson View Post
We can't use vectors (haven't learned them just yet) or remove the value from the array (asked not to, but this looks nice), only accepted way she was asking for was two for loops. I think I'm getting there though.

Code:
#include <iostream>
using namespace std;

int main()
{
int num[10];
bool is_dup = true;
cout << "Enter 10 numbers..." <<endl;
for (int i=0; i<10; i++)
{
        cin >> num[i];
}

for (int j=0; j<10;j++) //repeats 10 times
{
        for (int k=j; k>=0; k--) //this will repeat from j to 0
        {
                if (num[j] != num[k]) //checks if one number isn't equal to others below it
                is_dup = false; 
        }
        if (is_dup == false)
}
return 0;
}
I didn't finish it just yet. I just wanted to know if I'm making progress towards the right direction, and if what I'm doing makes sense.
When you say "Cannot remove the value from the array", what exactly are you supposed to do? print them out as you find numbers, but only if they aren't duplicates?

In this case, yeah, I guess you are in the right direction. Although I would say your check is inverted. Also, you need to start the loop at j-1, or you will test the number against itself.

Code:
is_dup = false; 
for (int k=j-1; k>=0; k--) //this will repeat from j-1 to 0
{
     if (num[j] == num[k]) //checks if one number is equal to others below it
  is_dup = true; //You found a duplicate.
}
if (is_dup == false) //No duplicates detected
    //do something
else
    //do nothing