1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
using namespace std;
int main()
{
int Array[17] = {7, 3, 32, 2, 55, 34, 6, 13, 29, 22, 11, 9, 1, 5, 42, 39, 8};
int n;
cout << "List = 7, 3, 32, 2, 55, 34, 6, 13, 29, 22, 11, 9, 1, 5, 42, 39, 8" << endl;
cout << "Enter an integer in the list to search for: ";
cin >> n;
int pos;
for(int i=0; i < 17; ++i)
{
if( Array[i] = n )
{
pos = i;
break;
}
else
continue;
}
cout << "Item found at index [" << pos << "]" << endl;
}
|