Comparing single element to all prior elements

I'm trying to develop code that will take in a bunch of digits (all 1-9), and place them all in an array. It will then determine how many numbers were entered before each digit (1,2,3,4,5,6,7,8,9) had all been entered once, on top of determining whether or not they had all been entered at all. I'm just a beginner and am baffled by this. I thought about doing nested for loops, but cannot figure a way to compare an element exclusively to those that preceded it.
this is where my planning has gotten me so far. Although I'm not sure if this will work... uses array digits[] for the inputted values, and array occurred[] to record the numbers that have occurred

for(int i=0; i<100; i++)
{
(read digits[i])

for(int j=0;j<8;j++)
{
if(digits[i] == occurred[j])
new= 'n';
}
if(new != 'n')
digits[i]>>occurred[];
}

am i at least on track??
your code:
new= 'n';

new is reserved keyword to alocate memory (you can't use it as a variable name)
Well you are on track. But I can't understand some of your code

1
2
3
4
5
6
7
8
9
10
11
12
13
for(int i=0; i<100; i++)
{
(read digits[i])   //What's this?

for(int j=0;j<8;j++)
{
if(digits[i] == occurred[j])
new= 'n';
}
if(new != 'n')
digits[i]>>occurred[];     // And What have you done here??
}
Thanks you guys. I didnt have my compiler at the computer i was at so i wasn't getting any debugging, which would explain why i was using "new" haha. and Pravesh the first line was where I was reading in user input, not in correct syntax. The second I was putting any digit values that passed that test into occurred (also incorrect syntax haha). Thanks you guys happy turkey holocaust day
Topic archived. No new replies allowed.