That still doesn't change the fact that when you enter twice the same number, it still stops the count and that's not the idea ;)
Like I said earlier, I'm not certain wether I need to do this with an array, the idea is solely to enter numbers and aslong as the amount of different numbers doesn't equal ten, I could enter one thousand numbers by manner of speaking and it would still run.
It ONLY stops for two reasons,:
1) when after a certain amount of numbers I type in a word or letter.
2) the amount of DIFFERENT numbers is equal to TEN!
int main()
{
const int amount=10;
int s[amount],n=0, x=0,y=0;
for (;;)
{
if (x==10) cout<< "The amount of different numbers has reached it's limit!"<<endl;
else
cin>>n;
++y;
for (int i=0;i<y;i++)
{
if (n==s[i])break;
if(s[i]>0 && n!=s[i])x++;
}
s[i]=n;
}
cout<<"The amount of different numbers is: "<< x <<endl;
return 0;
}
The problem with my code is that it allways increases x with one even if it allready has done this the previous time for the number.
I'll try and explain a bit better, if I have following numbers entered, 1, 45, 43, 54, 34, 63.
My code will compare them with eachother and increase x everytime it runs trough the array. So, it's like it compare's 1 with the others and this puts x equal to 5 and then it'll compare 45 with the others, meaning 43, 54, 34, 63 and this will put x equal to 9!
Of course, this is wrong because x should be equal to SIX and not NINE :D
DARN DARN, I tried several things, don't know what else I can try.
I also thought that I should fill an array first, but that's just it, the exercise states that the amount of numbers is random, so, you could type in one time five numbers and the next time fifthy, it should still work. Aslong as a) there aren't any more then TEN different numbers b) I don't type in a word or character!