Hello!
Here is the program code!
I wonder, if it is important if we put any other number instead key=0, or is there a reason that it must be exactly "0"?
Many thanks!
(we are searching if the key value is element of the field!)
int FindLinear(int field[],int value, int key)
{
for (int i=0; i<value; i++)
{
if (field[i]==key)
return i;
}
return -1;
}
int main(){
constint field_value=100;
int field2[field_value];
for (inr i=0; i<field_value; i++)
field2[[i]=2*i;
int key, result;
do
{
cout <<"write key value.";
cin>>key;
if (key!=0)
{
result= FindLInear(field2, field_value, key);
if (result!=-1)
cout<<"This value is in the filed on index: "<<result;
else
cout<<"This value is not in the field.";
}
}
while (key!=0);
return 0;
}
for (int i=0; i<