void getLottoPicks()
{
int i,k, num[7], num1;
bool nodup(int num[7],int k, int num1), noover= true;
for(i=0; i<7; i++)
num[i]=51;
cout << "please enter the seven numbers you think will win the lottery: "<< endl;
for (i=0; i<7;i++)
{
cin >> num[i];
if(num[i] < 1 || num[i] > 40)
{
i= i-1;
noover = false;
cout << "The number is out of range. Please enter a new number ";
}
if(noover)
{
num1=num[i];
k=i;
if (!nodup(num,k, num1))
{
i=i-1 ;
cout <<" you type the duplicated number. please enter another number";
}
}
}
}
bool nodup(int num[7],int i, int num1)
{
bool dup = false;
int k;
for(k=0; k<i-1; k++)
{
if (num[k] = num1)
dup = true;
}
return !dup;
}
every time i enter 2 of the same number it always couts ” you type the duplicated number. please enter another number”;
I think this line is wrong:
I think what it should be is: