void TestVector::sixElementVector()
{
vector<int> data(6);
int a = 0;
for (int i = 0; i < data.size(); i++)
{
cout << "Please enter a number between 10 and 101"
<< " to store" << endl;
int number = 0;
cin >> number;
if (number <= 101 && number >= 10 && number != data[0] && number != data[1] && number != data[2] && number != data[3] && number != data[4] && number != data[5])
{
data[a] = number; a++;
}
else
{
cout << "Incorrect entry\nPlease enter a number between 101 and 10!" << endl;
i--;
}
}
cout << data[0] << " " << data[1] << " " << data[2] << " " << data[3] << " " << data[4] << " " << data[5];
}
if(number <= 101 && number >= 10) // If it's not between 10 and 101 why even bother
// checking if it's equal to any other data
{
for(int j = 0; j < data.size(); j++) // if it is between 10 and 101. Then you can do this check using a for-loop
{
if(number != data[j]) //if the the number does not exist in the loop data vector, set data[a] to number
{
data[a] = number;
a++;
}
}
}
I cooked this up in a minute haven't 100% checked if it worked, try it :)
int a = 0;
for (int i = 0; i < data.size(); i++)
{
cout << "Please enter a number between 10 and 101"
<< " to store" << endl;
int number = 0;
cin >> number;
if (number <= 101 && number >= 10 && number != data[0] && number != data[1] && number != data[2] && number != data[3] && number != data[4] && number != data[5])
{